reflectasm icon indicating copy to clipboard operation
reflectasm copied to clipboard

Warnings with Java 9

Open zedaster opened this issue 7 years ago • 15 comments

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.esotericsoftware.reflectasm.AccessClassLoader (file:/C:/Users/Сергей/.m2/repository/com/esotericsoftware/reflectasm/1.11.7/reflectasm-1.11.7.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.reflectasm.AccessClassLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

zedaster avatar Aug 16 '18 19:08 zedaster

Some of my users are also seeing this. See rarcher/couch-potato-server#27 for a discussion.

rarcher avatar Oct 05 '18 16:10 rarcher

An option might be to create a multi release jar (aka MRJAR) and use a different way for Java 9+ to defineClass (MethodHandles.Lookup.defineClass).

magro avatar Jan 01 '19 12:01 magro

Any update?

TheMode avatar Aug 25 '19 20:08 TheMode

Can ignore or disable the warning.

NathanSweet avatar Aug 25 '19 20:08 NathanSweet

@NathanSweet Obviously. But can't the underlying problem be fixed?

cowwoc avatar Aug 25 '19 22:08 cowwoc

I'm not sure, I haven't looked into it. It's not a problem yet though, it's just a warning. It won't be a problem until they disallow what the library needs to function. At that time we either fix it or the library won't work on the latest JVMs. That is the case for a great many libraries.

NathanSweet avatar Aug 26 '19 07:08 NathanSweet

@NathanSweet For what it's worth, @magro explained how to fix this problem. Simply replace ClassLoader.defineClass with MethodHandles.Lookup.defineClass

cowwoc avatar Aug 26 '19 15:08 cowwoc

If that works, great! I just haven't had the time or personal need to dig into it.

NathanSweet avatar Aug 26 '19 19:08 NathanSweet

Any news on this?

jfida avatar Sep 30 '19 12:09 jfida

I'm running into this too, any idea of when a fix may be available.

thawkins avatar Nov 01 '19 01:11 thawkins

Just FYI: still the same warning with java 13

iverhun avatar Feb 04 '20 20:02 iverhun

Sorry I'm too busy with other things, but maybe someone could come up with a PR for multi-release jar?

magro avatar Apr 04 '20 08:04 magro

I tried to implement the suggestion of using MethodHandles.lookup().defineClass() instead of ClassLoader.defineClass(), but only got as far as https://github.com/robinverduijn/reflectasm/compare/fix-code-warnings...robinverduijn:fix-illegal-reflective-access. It left me with the warning gone but two tests failing. At that point I got stuck, but maybe someone else can figure out how to make it work from there?

robinverduijn avatar Apr 05 '20 00:04 robinverduijn

try this:

// suppress "An illegal reflective access operation has occurred" in JDK9+ if (!System.getProperty("java.version").startsWith("1.") && !MethodAccess.class.getModule().isNamed()) Class.class.getModule().addOpens(Class.class.getPackageName(), MethodAccess.class.getModule());

dwing4g avatar Nov 04 '20 07:11 dwing4g

In a similar vein to EsotericSoftware/kryo#626, could you support a System property (-Dreflectasm.unsafe=false) or something so that we can stop this error message from appearing (and ideally start to get ready for when illegal access is removed)? 🙏

soundasleep avatar Aug 10 '21 10:08 soundasleep