njit-jerse / specimin

SPECIfication MINimizer. A different kind of slicer for Java.
MIT License
0 stars 5 forks source link

error: package com.sun.tools.javac.code is not visible #303

Closed jonathan-m-phillips closed 2 weeks ago

jonathan-m-phillips commented 2 weeks ago

I received this error message, error: package com.sun.tools.javac.code is not visible, 100 times when running ASHE on the CF's javacutil directory.

The below successfully minimized: --args=--outputDirectory "/my/temp/dir" --root "/my/root/checker-framework/javacutil/src" --targetFile "main/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java" --targetMethod "org.checkerframework.javacutil.trees.DetachedVarSymbol#setDeclaration(VariableTree)" --jarPath "/path/to/checker-qual.jar"

Attempted Compiling Java files:

javac /my/temp/dir/main/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java
/my/temp/dir/main/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java:4: error: package com.sun.tools.javac.code is not visible
import com.sun.tools.javac.code.Symbol;
                          ^
  (package com.sun.tools.javac.code is declared in module jdk.compiler, which does not export it to the unnamed module)
/my/temp/dir/main/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java:5: error: package org.checkerframework.checker.nullness.qual does not exist
import org.checkerframework.checker.nullness.qual.Nullable;
                                                 ^
/my/temp/dir/main/java/org/checkerframework/javacutil/trees/DetachedVarSymbol.java:9: error: cannot find symbol
    @Nullable
     ^
  symbol:   class Nullable
  location: class DetachedVarSymbol
3 errors
kelloggm commented 2 weeks ago

@jonathan-m-phillips this looks like expected behavior to me. There are two issues:

  1. Specimin assumes that the jar files in the --jarPath argument will also be on the classpath when compiling the output. So, add -cp "/path/to/checker-qual.jar" when you try to compile Specimin's output. This will resolve two of the three errors (the one about the package not existing and the symbol not found one).
  2. the other error is caused by the fact that the target program uses non-exported parts of the JDK/compiler - in particular, com.sun.tools.javac.code.Symbol. When the original code is compiled, it must be compiled with a special flag. I think you need --add-exports $PACKAGE=ALL-UNNAMED, where $PACKAGE is the package being used (in this case com.sun.tools.javac.code).
kelloggm commented 2 weeks ago

I received this error message, error: package com.sun.tools.javac.code is not visible, 100 times when running ASHE on the CF's javacutil directory.

Are there examples that do not successfully minimize? If so, can you provide a Specimin command for them?

jonathan-m-phillips commented 2 weeks ago

@kelloggm Thank you for the solution to the problem I was facing!

Are there examples that do not successfully minimize? If so, can you provide a Specimin command for them?

I did not see any that were not successfully minimizing.

kelloggm commented 2 weeks ago

I did not see any that were not successfully minimizing.

Great, then I think we can close this issue.