diff --git a/app/PdePreprocessor.java b/app/PdePreprocessor.java index c2602abca..289102c90 100644 --- a/app/PdePreprocessor.java +++ b/app/PdePreprocessor.java @@ -78,8 +78,7 @@ public class PdePreprocessor { * @return the classname of the exported Java */ public String write(String program, String buildPath, - String name, String imports[], - int javaVersion) throws java.lang.Exception { + String name, String imports[]) throws java.lang.Exception { this.programReader = new StringReader(program); this.buildPath = buildPath; @@ -144,7 +143,7 @@ public class PdePreprocessor { PrintStream stream = new PrintStream( new FileOutputStream(buildPath + File.separator + name + ".java")); - writeHeader(stream, imports, javaVersion, name); + writeHeader(stream, imports, name); emitter.setOut(stream); emitter.print(rootNode); @@ -172,6 +171,7 @@ public class PdePreprocessor { return name; } + /** * Write any required header material (eg imports, class decl stuff) * @@ -180,7 +180,7 @@ public class PdePreprocessor { * @param name Name of the class being created. */ void writeHeader(PrintStream out, String imports[], - int javaVersion, String className) { + String className) { // emit emports that are needed for classes from the code folder if (imports != null) { @@ -191,7 +191,13 @@ public class PdePreprocessor { // emit standard imports (read from pde.properties) // for each language level that's being used. - for (int i = 0; i < javaVersion; i++) { + String jdkVersionStr = PdePreferences.get("compiler.jdk_version"); + + int jdkVersion = JDK11; // default + if (jdkVersionStr.equals("1.3")) { jdkVersion = JDK13 }; + if (jdkVersionStr.equals("1.4")) { jdkVersion = JDK14 }; + + for (int i = 0; i < jdkVersion; i++) { for (int j = 0; j < defaultImports[i].length; j++) { out.print("import " + defaultImports[i][j] + ".*; "); } diff --git a/app/PdeSketch.java b/app/PdeSketch.java index 77c39ce61..b844d22d1 100644 --- a/app/PdeSketch.java +++ b/app/PdeSketch.java @@ -470,11 +470,10 @@ public class Sketch { public String getMainFilePath() { return files[0].getAbsolutePath(); } - } class Code { - String name; + String name; // pretty name (no extension), not the full file name File file; int flavor; diff --git a/build/shared/lib/pde.properties b/build/shared/lib/pde.properties index c018dcf35..4b5193d9d 100644 --- a/build/shared/lib/pde.properties +++ b/build/shared/lib/pde.properties @@ -181,3 +181,15 @@ compiler.substitute_font = false # writes out the parse tree as parseTree.xml, which can be usefully # viewed in (at least) Mozilla or IE. useful when debugging the preprocessor. compiler.output_parse_tree = false + +# jdk version to use.. +compiler.jdk_version = 1.1 + +# base imports to include for java 1.1 (or higher) +compiler.imports.jdk11 = java.applet,java.awt,java.awt.image,java.awt.event,java.io,java.net,java.text,java.util,java.util.zip,netscape.javascript + +# additional imports when exporting to java 1.3 or higher +compiler.imports.jdk13 = javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi + +# additional imports when exporting to java 1.4 or higher +compiler.imports.jdk14 = javax.xml.parsers,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stream,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers diff --git a/todo.txt b/todo.txt index 932633f15..6f53e427e 100644 --- a/todo.txt +++ b/todo.txt @@ -35,6 +35,8 @@ X why won't loop() go bold? -> java 1.4 problem on the mac X test what it does on the pc X seems to be a mac-specific problem (probably because of monaco) X removed kjc classes +X addition to pde.properties to list the imports for various jdk versions +X set jdk version for export inside pde.properties goodbye macos9 X posted to message board about it going away