-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
The code that gets the Java compiler in JDecafCompiler seems to work in misterious ways:
a) If the file to compile exists and is a .jdc, everything works fine.
b) If the file does not exist or is not a .jdc, the compiler is not found.
private void compile(DecafFile[] files) throws Exception
{
boolean hacked = false;
String hackedJavaHomeBackup=System.getProperty("java.home");
//get an object to collect diagnostic messages
DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
//get a reference to the compiler
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
if (compiler == null) {
/* * * Hack to make this work on BBK's labs for now * * * */
System.out.println("No compiler found... using default...");
hacked = true;
System.setProperty("java.home", "C:\\Program Files\\Java\\jdk1.8.0_20");
compiler = ToolProvider.getSystemJavaCompiler();
System.out.println("Compiler: " + compiler);
for (DecafFile file : Arrays.asList(files))
System.out.println("File: " + file);
/* * * */
if (compiler == null) {
throw new ConfigurationException("No Java compiler available. Please review your local configuration.");
}
}
// ...etc....
` ` `
H:\JDecafCompiler\src\JDecafCompiler\source>java -cp .;..\lib\rsyntaxtextarea.jar JDecafCompiler h:\tmp\someFile.jdc
No compiler found... using default...
Compiler: com.sun.tools.javac.api.JavacTool@4617c264
File: someFile.java
H:\JDecafCompiler\src\JDecafCompiler\source>java -cp .;..\lib\rsyntaxtextarea.jar JDecafCompiler h:\tmp\someFile-noexist.jdc
h:\tmp\someFile-noexist.jdc cannot be found
No compiler found... using default...
can't open C:\Program Files\Java\jdk1.8.0_20\lib\tzmappings.
Compiler: null
File: null
Configuration Error: No Java compiler available. Please review your local configuration.
H:\JDecafCompiler\src\JDecafCompiler\source>java -cp .;..\lib\rsyntaxtextarea.jar JDecafCompiler h:\tmp\someFile.java
No compiler found... using default...
can't open C:\Program Files\Java\jdk1.8.0_20\lib\tzmappings.
Compiler: null
File: h:\tmp\someFile.java
Configuration Error: No Java compiler available. Please review your local config
uration.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels