-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test failures with OpenJDK17: probably ClassLoader evolutions since OpenJDK11 #89
Comments
This evaluates to It seems the difference from older JVMs is The As you found the classloaders are:
AccessClassLoader |
Hello, Thanks for looking at my issue. I had not noticed Package does not override equals. Thanks for the detailed explanation on why the class loaders are different. Yet I am afraid I don't understand your conclusion: as the first lines of the log I posted suggest, we expect an exception only with HasPrivateConstructor and not for the other tests. Do you mean the tests should be reworked in order to be considered successful even if this exception is met with HasPackageProtectedConstructor, HasProtectedConstructor and HasPublicConstructor? Best wishes, |
Java 17 disallows defining a class from bytes in the class loader that loaded AccessClassLoader. That is required for the access class to have package private (aka "default access") member access. This causes ConstructorAccessTest Sorry I didn't notice the other test failures. I see them now:
|
Hello, Thanks for the detailed explanation and for the fix. It certainly answers my concerns. Best, |
Hi @NathanSweet , sorry for bumping an old and closed issue, but I'm a bit unsure about a problem that we are seeing in our software, when upgrading to Java 17:
Is the problem here the same as in
Are you saying that it is no longer possible to use the loader |
I was able to get it work by updating reflectasm to use This way, as long as I can provide a Does this change make sense? I think this is exactly what Byte Buddy did for Java 11+, as described here http://mydailyjava.blogspot.com/2018/04/jdk-11-and-proxies-in-world-past.html?m=1 |
I don't have time at the moment to look deeper, but providing a |
From what I can see, currently the minimum version is 1.5. Also I'm not sure if you want to update the minimum version to 9? Edit: created #92 |
Hello,
I am maintaining reflectasm in Debian. We have recently switched from OpenJDK11 to OpenJDK17 and this caused failures in the tests in com.esotericsoftware.reflectasm.ConstructorAccessTest (output at the end of my report).
I digged a bit, ran testHasProtectedConstructor and looked at loader1, loader2 and systemClassLoader in AccessClassLoader.areInSameRuntimeClassLoader called by ConstructorAccess.get. They are respectively
jdk.internal.loader.ClassLoaders$AppClassLoader@46fbb2c1, com.esotericsoftware.reflectasm.AccessClassLoader@42d3bd8b , and jdk.internal.loader.ClassLoaders$AppClassLoader@46fbb2c1
when using OpenJDK17, whereas with OpenJDK11 they are respectively
jdk.internal.loader.ClassLoaders$AppClassLoader@55054057, jdk.internal.loader.ClassLoaders$AppClassLoader@55054057, and jdk.internal.loader.ClassLoaders$AppClassLoader@55054057
when using OpenJDK11. Thus I suspect something has changed in the ClassLoader mechanism, perhaps you would like to investigate.
Also, in AccessClassLoader.areInSameRuntimeClassLoader, I think you would like to use .equals() methods instead of == as, e.g. in
if (type1.getPackage() == type2.getPackage())
,you are willing to compare values and not references.
Cheers,
Pierre
[INFO] Running com.esotericsoftware.reflectasm.ConstructorAccessTest
Unexpected exception happened: java.lang.RuntimeException: Class cannot be created (the no-arg constructor is protected or package-protected, and its ConstructorAccess could not be defined in the same class loader): com.esotericsoftware.reflectasm.ConstructorAccessTest$HasProtectedConstructor
Unexpected exception happened: java.lang.RuntimeException: Class cannot be created (the no-arg constructor is protected or package-protected, and its ConstructorAccess could not be defined in the same class loader): com.esotericsoftware.reflectasm.ConstructorAccessTest$HasPublicConstructor
Expected exception happened: java.lang.RuntimeException: Class cannot be created (missing no-arg constructor): com.esotericsoftware.reflectasm.ConstructorAccessTest$HasArgumentConstructor
Unexpected exception happened: java.lang.RuntimeException: Class cannot be created (the no-arg constructor is protected or package-protected, and its ConstructorAccess could not be defined in the same class loader): com.esotericsoftware.reflectasm.ConstructorAccessTest$HasPackageProtectedConstructor
Expected exception happened: java.lang.RuntimeException: Class cannot be created (the no-arg constructor is private): com.esotericsoftware.reflectasm.ConstructorAccessTest$HasPrivateConstructor
[ERROR] Tests run: 7, Failures: 3, Errors: 1, Skipped: 0, Time elapsed: 0.057 s <<< FAILURE! - in com.esotericsoftware.reflectasm.ConstructorAccessTest
[ERROR] testHasProtectedConstructor(com.esotericsoftware.reflectasm.ConstructorAccessTest) Time elapsed: 0.029 s <<< FAILURE!
junit.framework.AssertionFailedError
at com.esotericsoftware.reflectasm.ConstructorAccessTest.testHasProtectedConstructor(ConstructorAccessTest.java:74)
[ERROR] testHasPublicConstructor(com.esotericsoftware.reflectasm.ConstructorAccessTest) Time elapsed: 0.004 s <<< FAILURE!
junit.framework.AssertionFailedError
at com.esotericsoftware.reflectasm.ConstructorAccessTest.testHasPublicConstructor(ConstructorAccessTest.java:98)
[ERROR] testPackagePrivateNewInstance(com.esotericsoftware.reflectasm.ConstructorAccessTest) Time elapsed: 0.002 s <<< ERROR!
java.lang.RuntimeException: Class cannot be created (the no-arg constructor is protected or package-protected, and its ConstructorAccess could not be defined in the same class loader): com.esotericsoftware.reflectasm.ConstructorAccessTest$PackagePrivateClass
at com.esotericsoftware.reflectasm.ConstructorAccessTest.testPackagePrivateNewInstance(ConstructorAccessTest.java:31)
[ERROR] testHasPackageProtectedConstructor(com.esotericsoftware.reflectasm.ConstructorAccessTest) Time elapsed: 0.007 s <<< FAILURE!
junit.framework.AssertionFailedError
at com.esotericsoftware.reflectasm.ConstructorAccessTest.testHasPackageProtectedConstructor(ConstructorAccessTest.java:86)
The text was updated successfully, but these errors were encountered: