| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,12 @@ public abstract class Mode { | |||
| 51 | 51 | ||
| 52 | 52 | /** Library folder for core. (Used for OpenGL in particular.) */ | |
| 53 | 53 | protected Library coreLibrary; | |
| 54 | + | ||
| 55 | + /** | ||
| 56 | + * ClassLoader used to retrieve classes for this mode. Useful if you want | ||
| 57 | + * to grab any additional classes that subclass what's in the mode folder. | ||
| 58 | + */ | ||
| 59 | + protected ClassLoader classLoader; | ||
| 54 | 60 | ||
| 55 | 61 | ||
| 56 | 62 | // public Mode(Base base, File folder) { | |
@@ -71,6 +77,16 @@ public Mode(Base base, File folder) { | |||
| 71 | 77 | rebuildLibraryList(); | |
| 72 | 78 | // rebuildExamplesMenu(); | |
| 73 | 79 | } | |
| 80 | + | ||
| 81 | + | ||
| 82 | + public void setClassLoader(ClassLoader loader) { | ||
| 83 | + this.classLoader = loader; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + | ||
| 87 | + public ClassLoader getClassLoader() { | ||
| 88 | + return classLoader; | ||
| 89 | + } | ||
| 74 | 90 | ||
| 75 | 91 | ||
| 76 | 92 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,6 +96,7 @@ private ModeContribution(Base base, File folder, | |||
| 96 | 96 | Class<?> modeClass = loader.loadClass(className); | |
| 97 | 97 | Constructor con = modeClass.getConstructor(Base.class, File.class); | |
| 98 | 98 | mode = (Mode) con.newInstance(base, folder); | |
| 99 | + mode.setClassLoader(loader); | ||
| 99 | 100 | mode.setupGUI(); | |
| 100 | 101 | } | |
| 101 | 102 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,7 +82,6 @@ public void run() { | |||
| 82 | 82 | String[] jarList = new String[] { | |
| 83 | 83 | "pde.jar", | |
| 84 | 84 | "antlr.jar", | |
| 85 | - "jdt-core.jar", | ||
| 86 | 85 | "jna.jar", | |
| 87 | 86 | "ant.jar", | |
| 88 | 87 | "ant-launcher.jar", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,9 +27,10 @@ | |||
| 27 | 27 | import processing.core.*; | |
| 28 | 28 | ||
| 29 | 29 | import java.io.*; | |
| 30 | + import java.lang.reflect.Method; | ||
| 30 | 31 | ||
| 31 | - import org.eclipse.jdt.core.compiler.batch.BatchCompiler; | ||
| 32 | - import org.eclipse.jdt.core.compiler.CompilationProgress; | ||
| 32 | + //import org.eclipse.jdt.core.compiler.batch.BatchCompiler; | ||
| 33 | + //import org.eclipse.jdt.core.compiler.CompilationProgress; | ||
| 33 | 34 | ||
| 34 | 35 | ||
| 35 | 36 | public class Compiler { | |
@@ -107,10 +108,31 @@ public void close() { } | |||
| 107 | 108 | PrintWriter writer = new PrintWriter(internalWriter); | |
| 108 | 109 | ||
| 109 | 110 | //result = com.sun.tools.javac.Main.compile(command, writer); | |
| 110 | - | ||
| 111 | - CompilationProgress progress = null; | ||
| 111 | + | ||
| 112 | 112 | PrintWriter outWriter = new PrintWriter(System.out); | |
| 113 | - success = BatchCompiler.compile(command, outWriter, writer, progress); | ||
| 113 | + | ||
| 114 | + // Version that's not dynamically loaded | ||
| 115 | + //CompilationProgress progress = null; | ||
| 116 | + //success = BatchCompiler.compile(command, outWriter, writer, progress); | ||
| 117 | + | ||
| 118 | + // Version that *is* dynamically loaded. First gets the mode class loader | ||
| 119 | + // so that it can grab the compiler JAR files from it. | ||
| 120 | + ClassLoader loader = build.mode.getClassLoader(); | ||
| 121 | + try { | ||
| 122 | + Class batchClass = | ||
| 123 | + Class.forName("org.eclipse.jdt.core.compiler.batch.BatchCompiler", false, loader); | ||
| 124 | + Class progressClass = | ||
| 125 | + Class.forName("org.eclipse.jdt.core.compiler.CompilationProgress", false, loader); | ||
| 126 | + Class[] compileArgs = | ||
| 127 | + new Class[] { String[].class, PrintWriter.class, PrintWriter.class, progressClass }; | ||
| 128 | + Method compileMethod = batchClass.getMethod("compile", compileArgs); | ||
| 129 | + success = (Boolean) | ||
| 130 | + compileMethod.invoke(null, new Object[] { command, outWriter, writer, null }); | ||
| 131 | + } catch (Exception e) { | ||
| 132 | + e.printStackTrace(); | ||
| 133 | + throw new SketchException("Unknown error inside the compiler."); | ||
| 134 | + } | ||
| 135 | + | ||
| 114 | 136 | // Close out the stream for good measure | |
| 115 | 137 | writer.flush(); | |
| 116 | 138 | writer.close(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,7 +37,7 @@ | |||
| 37 | 37 | <fileset dir=".." id="runtime.jars"> | |
| 38 | 38 | <include name="app/pde.jar" /> | |
| 39 | 39 | <include name="app/lib/antlr.jar" /> | |
| 40 | - <include name="app/lib/jdt-core.jar" /> | ||
| 40 | + <!-- <include name="app/lib/jdt-core.jar" />--> | ||
| 41 | 41 | <include name="app/lib/jna.jar" /> | |
| 42 | 42 | <include name="app/lib/ant.jar" /> | |
| 43 | 43 | <include name="app/lib/ant-launcher.jar" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,7 +81,7 @@ | |||
| 81 | 81 | <!-- In 0149, removed /System/Library/Java from the CLASSPATH because | |
| 82 | 82 | it can cause problems if users have installed weird files there. | |
| 83 | 83 | http://dev.processing.org/bugs/show_bug.cgi?id=1045 --> | |
| 84 | - <string>$JAVAROOT/pde.jar:$JAVAROOT/core/library/core.jar:$JAVAROOT/ant.jar:$JAVAROOT/ant-launcher.jar:$JAVAROOT/antlr.jar:$JAVAROOT/jdt-core.jar:$JAVAROOT/jna.jar:$JAVAROOT/quaqua.jar</string> | ||
| 84 | + <string>$JAVAROOT/pde.jar:$JAVAROOT/core/library/core.jar:$JAVAROOT/ant.jar:$JAVAROOT/ant-launcher.jar:$JAVAROOT/antlr.jar:$JAVAROOT/jna.jar:$JAVAROOT/quaqua.jar</string> | ||
| 85 | 85 | ||
| 86 | 86 | <!-- More properties can be found in http://developer.apple.com/releasenotes/Java/java141/system_properties/chapter_4_section_1.html#//apple_ref/doc/uid/TP30000285 --> | |
| 87 | 87 | <key>Properties</key> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,6 @@ | |||
| 18 | 18 | <cp>lib/pde.jar</cp> | |
| 19 | 19 | <cp>core/library/core.jar</cp> | |
| 20 | 20 | <cp>lib/jna.jar</cp> | |
| 21 | - <cp>lib/jdt-core.jar</cp> | ||
| 22 | 21 | <cp>lib/antlr.jar</cp> | |
| 23 | 22 | <cp>lib/ant.jar</cp> | |
| 24 | 23 | <cp>lib/ant-launcher.jar</cp> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,7 +18,6 @@ | |||
| 18 | 18 | <cp>lib/pde.jar</cp> | |
| 19 | 19 | <cp>core/library/core.jar</cp> | |
| 20 | 20 | <cp>lib/jna.jar</cp> | |
| 21 | - <cp>lib/jdt-core.jar</cp> | ||
| 22 | 21 | <cp>lib/antlr.jar</cp> | |
| 23 | 22 | <cp>lib/ant.jar</cp> | |
| 24 | 23 | <cp>lib/ant-launcher.jar</cp> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments