Skip to content
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

Java 11 Compatibility check: CGLIb #133

Open
KryniuPL opened this issue Aug 16, 2018 · 3 comments
Open

Java 11 Compatibility check: CGLIb #133

KryniuPL opened this issue Aug 16, 2018 · 3 comments

Comments

@KryniuPL
Copy link

Hi,
We are reaching out to you to check Java 11 compatibility of the library CGLIb.

Could you help us by answering the following questions:

  1. Library Name:
  2. Latest version: <latest 1.1.1="" eg:="" version.="">
  3. Latest version Is the library compatible with Java 11 Compatible? (Y/N)
  4. Is the library supported with Java 11? (Y/N)
  5. (If “N” in compatibility or support) What is the versions that would be compatible and Supported?
  6. Date of support availability?

Appreciate your response by 19.08.2018.

Thanks,
Krzysztof Dragan,
PTC Inc. Contractor

@lomboz
Copy link

lomboz commented Oct 2, 2018

Hi,
i have checked cglib version 3.2.8 on final jdk 11 and get the following warnings.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/C:/Entwicklung/mvn_repo/cglib/cglib/3.2.8/cglib-3.2.8.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 net.sf.cglib.core.ReflectUtils$1
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

Can i ignore this warnings or how can i solved this?

@KryniuPL
Copy link
Author

KryniuPL commented Oct 2, 2018

These are just warnings, from Java 9 jdk is much more restrictive concerning reflective access to non-public fields/methods.
There are some ways to fix these warnings.
https://blog.codefx.org/java/java-9-migration-guide/#Illegal-Access-To-Internal-APIs

@garretwilson
Copy link

I'm pulling out and dusting off some really old code, bringing it up to date with Java 11. I'm using cglib 3.2.9 with OpenJDK on Windows 10. The code is trying to enhance a type that has a URI constructor. Here is the call:

final T object = objectClass.cast(enhancer.create(constructor.getParameterTypes(), arguments))

The parameter types has "URI", and the arguments contains a URI. This gives me (output from JUnit ran within Eclipse):

net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
	at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:345)
	at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492)
	at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
	at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
	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:116)
	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
	at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
	at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:324)
	at [this is the code I mentioned above]
	at [this is my JUnit unit test]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:459)
	at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:336)
	... 40 more
Caused by: java.lang.ClassFormatError: Duplicate method name "newInstance" with signature "([Lnet.sf.cglib.proxy.Callback;)Ljava.lang.Object;" in class file com/example/FooBar$$EnhancerByCGLIB$$11443bd3$$EnhancerByCGLIB$$1ecbb6c1
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
	... 46 more

I don't have time to investigate this right now (we're concentrating on updating another part of the library first), and I'm reading elsewhere that we should switch to Byte Buddy for Java 11. I'm including this in case it's helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants