Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find method sun.misc.Unsafe.defineClass

I am using jdk-10.0.2 and gradle 4.7, I am getting this error while building my project.

    Unable to find method 'sun.misc.Unsafe.defineClass(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;'.

Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
like image 827
daemonThread Avatar asked Apr 30 '19 10:04

daemonThread


1 Answers

I had the same issue (but using JDK 11):

Unable to find method 'sun.misc.Unsafe.defineClass(Ljava/lang/String;[BIILjava/lang/ClassLoader;Ljava/security/ProtectionDomain;)Ljava/lang/Class;'.

with version gradle 4.7 as you.

My gradle-wrapper.properties file was:

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip

To solve the issue I changed to 4.9 version of wrapper using parameter distributionUrl:

 distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip

And rebuild the project without any errors.

like image 145
invzbl3 Avatar answered Nov 15 '22 17:11

invzbl3