Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
javassist cannot work on jdk 16 #369
javassist cannot work on jdk 16 #369
Comments
When I test sample code of #344 (javassist not work for jdk version 11.0.7) on jdk 16,it fails and throws a InaccessibleObjectException.
Exception in thread «main» java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not «opens java.lang» to unnamed module @5c0369c4 at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) at javassist.util.proxy.SecurityActions.setAccessible(SecurityActions.java:159) at javassist.util.proxy.DefineClassHelper$JavaOther.defineClass(DefineClassHelper.java:213) at javassist.util.proxy.DefineClassHelper$Java11.defineClass(DefineClassHelper.java:52) at javassist.util.proxy.DefineClassHelper.toClass(DefineClassHelper.java:260)
So I wonder whether the sample is not right on jdk16 or javassit is not ready for the new jdk.
The text was updated successfully, but these errors were encountered:
@NingZhang-e thank you for your solution,it does work.By the way, will the ctClass.toClass() method be deprecated in the future?
Do you think it should be @deprecated now?
It works if you’re using JDK 8 or so.
I do not think it should be deprecated now unless javassist only support >JDK11 , but it will support JDK 8 for some time.
And one thing to mention, even toClass() could be supported on JDK8, but if the jars in classpath are signed jars, you might need to switch to:
cc.toClass(Thread.currentThread().getContextClassLoader(), neighborClass.getProtectionDomain());
* Update `mockito` -> 4.8.1 Update `mockito` to version 4.8.1, which is the latest version at this time. Update `OEmbedClientImplTest` and `ContainerServletTest`to remove references to removed class`org.mockito.internal.util.reflection.FieldSetter`. `org.apache.commons.lang3.reflect.FieldUtils` is used instead. In `AmpModeForwardFilterTest`, the deprecated and removed `anyObject()` method is removed and replaced with `ArgumentMatchers.any()`. * Update `caconfig-mock-plugin` -> 1.4.0 Update `caconfig-mock-plugin` to version 1.4.0, which is the latest version at this time. Version 1.3.4 or higher is required for newer versions of `aem-mock` (>=4.1.6). * Upgrade `junit-jupiter` -> 5.9.1 — Update `junit-jupiter` to version 5.9.1. — Remove any reference to junit4 in `DependencyManagement` because the dependencies are no longer used. — Replace `junit-jupter-api/params/engine` dependencies with `junit-jupiter` because it is no longer required to include each individual dependency. * Update `aem-mock` -> 5.1.0 Update `io.wcm.testing.aem-mock.junit5` to version 5.1.0. — `MockExternalizerFactory` is deprecated in favour of using the `MockExternalizer` which is part of `aem-mock` since version 4.1.0. — Update tests to remove usage of `MockExternalizer`. — Correct incorrect `@type` values in exporter tests (which were the result of a limitation in previous versions of `aem-mock`. * Update dependencies Update dependencies that do not require any specific code changes to upgrade. * Update spotbugs -> 4.7.2.1 Updates `spotbugs` plugin from version 4.0.4 to version 4.7.2.1. This causes many `EI_EXPOSE_REP` and `EI_EXPOSE_REP2` errors to be spotted. These are suppressed for the time being. * Don’t use reflection to test loggers Update tests of log messages to use a custom log appender instead of using reflection to override the private static logger. * Fix JDK17 reflection error in `FormsHelperStubber` replace use of `CtClass.toClass()` with `CtClass.toClass(Class neighbour)` in `FormsHelperStubber`. This is required for Java 17. For more information see discussion: jboss-javassist/javassist#369 * Change `ContanerServletTest` to JCR_MOCK Change `ContainerServletTest` to use JCR_MOCK instead of OAK_MOCK. * Don’t require values to be string in `CoreResourceWrapper` Change the value type from `String` -> `Object` in `CoreResourceWrapper` so that it matches up with what is allowed as per the `ValueMap` interface. This prevents unessisary use of string values (such as `»true»` instead of `true` or `Boolean.TRUE`). * Remove unnecessary use of `MockSlingHttpServletRequest` Remove use of `MockSlingHttpServletRequest` when it is unnecessary because a `MockSlingHttpServletRequest` already exists via the `AemContext`. * Fix `AdaptiveImageServletMappingConfigurationConsumerTest` Reorder service activation to ensure services are bound to component. The requirement to do this is likely related to SLING-11668 (https://issues.apache.org/jira/browse/SLING-11668). * Update Image V3 test data Replace the use of `»ture»` and `»false»` in the V3 image test data with `true` and `false` (i.e. boolean instead of string). This appears to be required when building in Java 17, possibly due to an issue with the converter in Java 12+. See FELIX-6157: https://issues.apache.org/jira/browse/FELIX-6157. * Remove `FormsHelperStubber` `FormsHelperStubber` uses reflection to modify the `FormsHelper` class provided by AEM. This is done with the help of the `javassist` test dependency. There is no (reasonable) update that could be made to allow this to function in both Java 8 and Java 17. To correct this issue, `FormsHelperStubber` is removed entirely and replaced with an actual stub of the class `day.cq.wcm.foundation.forms.FormsHelper`. * Add license to `logback.xml` Adds Adobe license header to `logback.xml` as required by the rat plugin. * Test servlet deregistration on deactivet of configuration consumer Adds test validating that the Servlets registered by `AdaptiveImageServletMappingConfigurationConsumer` are removed when the `#deactivat()` method is called. Co-authored-by: Burkhard Pauli
There is some case, when a target class has no neighbor, can we support input package name, or parse package automatically? Thanks!
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
Java 16 and 17 compatibility #191
Java 16 and 17 compatibility #191
Comments
Upgrading to Java 16 I receive the following Exception. I tried adding the VM option —add-opens java.base/java.lang=ALL-UNNAMED which I thought would work around the issue to no avail.
Exception in thread "main" java.lang.ExceptionInInitializerError at com.example.main(Example.java:10) Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @39aeed2f at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:464) at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:339) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94) at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119) at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294) at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:221) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:174) at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:153) at net.sf.cglib.proxy.Enhancer.(Enhancer.java:73) . 1 more Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @39aeed2f at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357) at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297) at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199) at java.base/java.lang.reflect.Method.setAccessible(Method.java:193) at net.sf.cglib.core.ReflectUtils$1.run(ReflectUtils.java:61) at java.base/java.security.AccessController.doPrivileged(AccessController.java:554) at net.sf.cglib.core.ReflectUtils.(ReflectUtils.java:52) at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:243) at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332) . 13 more
The text was updated successfully, but these errors were encountered: