Learn, Share, Build

151
October 08, 2017, at 05:16 AM

I've got a very simple program:

Test.java:

package com;
import sun.misc.Contended;
public class Test {
}

and pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                              http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>Test</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
    <maven.compiler.source>1.9</maven.compiler.source>
    <maven.compiler.target>1.9</maven.compiler.target>
</properties>
</project>

when I put mvn compile I've got:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project proj: Compilation failure
[ERROR] /home/john/Desktop/proj/src/main/java/com/Test.java: cannot find symbol
[ERROR] symbol:   class Contended
[ERROR] location: package sun.misc

Why?

Answer 1

Because, sun.misc moved to jdk.internal.misc and they are private package to JDK.

... friend interfaces should be moved out of 'sun.misc' and located in a truly private package. This is so that they are not part of the proposed to be exported 'sun.misc' package.

You can use --add-exports and --add-opens to gain access to internal API.

In your case, you can add following in your pom.xml

<compilerArgs>
   <arg>--add-exports</arg>
   <arg>java.base/jdk.internal.misc=<<your.module>></arg>
</compilerArgs>

Please note, you need to change <<your.module>> to your actual module name.

Reference : - JEP-261:Module System

READ ALSO
Learn, Share, Build

Learn, Share, Build

The { symbol is not working in eclipseIf I try to use it, it turns on and off the Skip All Breakpoints opportunity

139
Learn, Share, Build

Learn, Share, Build

Suppose I have a synchronized block on an Object lock

142
Learn, Share, Build

Learn, Share, Build

I try to debug Java code on Visual Studio Code, but I always get this error Failed to resolve classpath: Main class '<name of mainclass here>' doesn't exist in the workspaceI need help

214
Learn, Share, Build

Learn, Share, Build

I have an application created in Spring Boot https://githubcom/JonkiPro/REST-Web-Services

159