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

Compatibility to JDK 8 and JDK 9 at the same time? #171

Closed
cnsgithub opened this issue Nov 20, 2017 · 6 comments
Closed

Compatibility to JDK 8 and JDK 9 at the same time? #171

cnsgithub opened this issue Nov 20, 2017 · 6 comments

Comments

@cnsgithub
Copy link

cnsgithub commented Nov 20, 2017

Hi, is the next version supposed to support JDK9 and JDK8? I'm currently experiencing this exception when running the master on JDK8. Or is there a 'special' way i need to build the jar?

Caused by: java.lang.NoClassDefFoundError: java/lang/StackWalker$Option
	at javassist.util.proxy.DefineClassHelper$SecuredPrivileged$1.<init>(DefineClassHelper.java:67)
	at javassist.util.proxy.DefineClassHelper$SecuredPrivileged.<clinit>(DefineClassHelper.java:38)
	at javassist.util.proxy.DefineClassHelper.<clinit>(DefineClassHelper.java:177)
	at javassist.util.proxy.FactoryHelper.toClass(FactoryHelper.java:128)
	at javassist.util.proxy.ProxyFactory.createClass3(ProxyFactory.java:552)
	at javassist.util.proxy.ProxyFactory.createClass2(ProxyFactory.java:537)
	at javassist.util.proxy.ProxyFactory.createClass1(ProxyFactory.java:473)
	at javassist.util.proxy.ProxyFactory.createClass(ProxyFactory.java:444)
	at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.postInstantiate(JavassistProxyFactory.java:75)
	at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
	at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:163)
	at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:58)
	... 131 more
Caused by: java.lang.ClassNotFoundException: java.lang.StackWalker$Option
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at org.jboss.modules.JDKSpecific.getSystemClass(JDKSpecific.java:183)
	at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:397)
	at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
	... 143 more

P.S Would it be possible to get a build of the 'master' somewhere? So i don't have to build it? Unfortunately the latest GA release causes a NPE (which has been fixed in a later commit)

@nickl-
Copy link
Contributor

nickl- commented Nov 27, 2017

Hi, is the next version supposed to support JDK9 and JDK8? I'm currently experiencing this exception when running the master on JDK8. Or is there a 'special' way i need to build the jar?

Currently the tests require java 9 and I have not tested a build with 1.8 so have no idea.

I know we are building source=1.6 so the idea is to be able to run the compiled sources against even a 1.6 vm, this is also not tested yet.

Would it be possible to get a build of the 'master' somewhere? So i don't have to build it? Unfortunately the latest GA release causes a NPE (which has been fixed in a later commit)

As far as I know, at the time of this writing, the latest release is 3.22.0-GA (October 10th) but the repository does include a file javassist.jar in the root of the project which was last build November 15th and should include everything committed up to and including this date.

Please let us know what find...

@mads1980
Copy link

I can confirm that 3.22.0 does not work in Java 8 since StackWalker is not present and we get a NoClassDefFoundError

Seems we need to stick to 3.21.0 in Java 8 until this is resolved.

@nickl-
Copy link
Contributor

nickl- commented Apr 21, 2018

This is designated JAVA_9 not sure why JDK8 would try and interpret the StackWalker.

JAVA_9 {
final class ReferencedUnsafe
{
private final SecurityActions.TheUnsafe sunMiscUnsafeTheUnsafe;
private final MethodHandle defineClass;
ReferencedUnsafe(SecurityActions.TheUnsafe usf, MethodHandle meth)
{
this.sunMiscUnsafeTheUnsafe = usf;
this.defineClass = meth;
}
Class<?> defineClass(String name, byte[] b, int off, int len,
ClassLoader loader, ProtectionDomain protectionDomain)
throws ClassFormatError {
if (stack.getCallerClass() != SecuredPrivileged.JAVA_9.getClass())
throw new IllegalAccessError("Access denied for caller.");
try {
return (Class<?>) defineClass.invokeWithArguments(
sunMiscUnsafeTheUnsafe.theUnsafe,
name, b, off, len, loader, protectionDomain);
} catch (Throwable e) {
if (e instanceof RuntimeException) throw (RuntimeException) e;
if (e instanceof ClassFormatError) throw (ClassFormatError) e;
throw new ClassFormatError(e.getMessage());
}
}
}
private final StackWalker stack = StackWalker
.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);

@beikov
Copy link
Contributor

beikov commented Jun 22, 2018

I just ran into the same issue. I wanted to update to 3.23.0 to test with JDK 11, but when running on JDK 8 with that version, I also get this error.

beikov added a commit to beikov/javassist that referenced this issue Jun 22, 2018
chibash added a commit that referenced this issue Jun 23, 2018
[#171] Allow running on JDK 8 and possibly on JDK 7 as well. Fixes #171
@arungitan
Copy link

just to confirm - if we have a requirement to run on both java8 and java11 (our code is compiled on java8), should we use v23 or wait for next version?

@johnou
Copy link

johnou commented Jun 27, 2018

@arungitan wait for next version, see #204 (comment)

odl-github pushed a commit to opendaylight/odlparent that referenced this issue Aug 9, 2018
jboss-javassist/javassist#165
jboss-javassist/javassist#171

Change-Id: I6ebb2e837a8acffdc3a5cc9830d0a1b9d2c0d375
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
odl-github pushed a commit to opendaylight/odlparent that referenced this issue Aug 10, 2018
jboss-javassist/javassist#165
jboss-javassist/javassist#171

Change-Id: I6ebb2e837a8acffdc3a5cc9830d0a1b9d2c0d375
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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

6 participants