Home > front end >  JNI error: sun.misc.Unsafe.defineClass: name or signature does not match
JNI error: sun.misc.Unsafe.defineClass: name or signature does not match

Time:12-31

java/lang/NoSuchMethodError:
  Method sun.misc.Unsafe.defineClass(Ljava/lang/String;[BII)Ljava/lang/Class;
  name or signature does not match

See the following picture:

Error message

After adding org.aspectj dependency, everything is OK, but what is the reason?

<dependency>
  <groupId>org.aspectj</groupId>
  <artifactId>aspectjrt</artifactId>
  <version>1.8.0</version>
</dependency>

CodePudding user response:

Actually, the more interesting part of your stack trace is:

java/lang/NoClassDefFoundError: org/aspectj/lang/Signature

The reason is that (at least part of) your code has been compiled with the AspectJ compiler. In order for AspectJ to work, you need the AspectJ runtime on your classpath. So far, so simple.

CodePudding user response:

Looking at the source code for Java 1.8.0.262-ga, that particular overload for Unsafe.defineClass no longer exists. It was previously deprecated and by 262 it had been removed entirely.

Presumably the version of the AspectJ runtime you were using previously was using the removed overload. The version you are now is presumably more recent ... and no longer uses the removed overload.

  • Related