| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | SourceCompiler.
An in-memory class file manager. |
| private static class | SourceCompiler.
Access the Groovy compiler using reflection, so that we do not gain a compile-time dependency unnecessarily. |
| pack-priv static class | SourceCompiler.
An in-memory java class object. |
| pack-priv static class | SourceCompiler.
An in-memory java source file object. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| pack-priv final HashMap | compiled
The class name to byte code map. |
| pack-priv final Map | compiledScripts
The class name to compiled scripts map. |
| pack-priv static final JavaCompiler | JAVA_COMPILER
The "com.sun.tools.javac.Main" (if available). |
| private static final Class | |
| pack-priv final HashMap | sources
The class name to source code map. |
| pack-priv boolean | useJavaSystemCompiler
Whether to use the ToolProvider.getSystemJavaCompiler(). |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| private static int | |
| public Class | |
| public CompiledScript | Returns: the compiled scriptthe package and class name packageAndClassName)Get the compiled script. |
| pack-priv static String | Returns: the full source codethe package name packageName, String the class name className, String the (possibly shortened) source code source)Get the complete source code (including package name, imports, and so on). |
| public Method | |
| private static void | |
| private static boolean | |
| private static boolean | |
| public static boolean | isJavaxScriptSource(String
the source to test. source)Whether the passed source can be compiled using |
| private static boolean | |
| pack-priv byte[] | Returns: the class filethe package name packageName, String the class name className, String the source code source)Compile the given class. |
| private static void | |
| private static synchronized void | |
| pack-priv Class | Returns: the classthe package name packageName, String the class name className, String the source code source)Compile using the standard java compiler. |
| public void | setJavaSystemCompiler(boolean
true to enable enabled)Enable or disable the usage of the Java system compiler. |
| public void |
| COMPILE_DIR | back to summary |
|---|---|
| private static final String COMPILE_DIR | |
| compiled | back to summary |
|---|---|
| pack-priv final HashMap<String, Class<?>> compiled The class name to byte code map. | |
| compiledScripts | back to summary |
|---|---|
| pack-priv final Map<String, CompiledScript> compiledScripts The class name to compiled scripts map. | |
| JAVA_COMPILER | back to summary |
|---|---|
| pack-priv static final JavaCompiler JAVA_COMPILER The "com.sun.tools.javac.Main" (if available). | |
| JAVAC_SUN | back to summary |
|---|---|
| private static final Class<?> JAVAC_SUN | |
| sources | back to summary |
|---|---|
| pack-priv final HashMap<String, String> sources The class name to source code map. | |
| useJavaSystemCompiler | back to summary |
|---|---|
| pack-priv boolean useJavaSystemCompiler Whether to use the ToolProvider.getSystemJavaCompiler(). | |
| SourceCompiler | back to summary |
|---|---|
| public SourceCompiler() | |
| copyInThread | back to summary |
|---|---|
| private static void copyInThread(final InputStream in, final OutputStream out) | |
| exec | back to summary |
|---|---|
| private static int exec(String... args) | |
| getClass | back to summary |
|---|---|
| public Class Get the class object for the given name.
| |
| getCompiledScript | back to summary |
|---|---|
| public CompiledScript getCompiledScript(String packageAndClassName) throws ScriptException Get the compiled script.
| |
| getCompleteSourceCode | back to summary |
|---|---|
| pack-priv static String getCompleteSourceCode(String packageName, String className, String source) Get the complete source code (including package name, imports, and so on). | |
| getMethod | back to summary |
|---|---|
| public Method getMethod(String className) throws ClassNotFoundException Get the first public static method of the given class.
| |
| handleSyntaxError | back to summary |
|---|---|
| private static void handleSyntaxError(String output, int exitStatus) | |
| isGroovySource | back to summary |
|---|---|
| private static boolean isGroovySource(String source) | |
| isJavascriptSource | back to summary |
|---|---|
| private static boolean isJavascriptSource(String source) | |
| isJavaxScriptSource | back to summary |
|---|---|
| public static boolean isJavaxScriptSource(String source) Whether the passed source can be compiled using
| |
| isRubySource | back to summary |
|---|---|
| private static boolean isRubySource(String source) | |
| javacCompile | back to summary |
|---|---|
| pack-priv byte[] javacCompile(String packageName, String className, String source) Compile the given class. This method tries to use the class "com.sun.tools.javac.Main" if available. If not, it tries to run "javac" in a separate process. | |
| javacProcess | back to summary |
|---|---|
| private static void javacProcess(Path javaFile) | |
| javacSun | back to summary |
|---|---|
| private static synchronized void javacSun(Path javaFile) | |
| javaxToolsJavac | back to summary |
|---|---|
| pack-priv Class Compile using the standard java compiler. | |
| setJavaSystemCompiler | back to summary |
|---|---|
| public void setJavaSystemCompiler(boolean enabled) Enable or disable the usage of the Java system compiler.
| |
| setSource | back to summary |
|---|---|
| public void setSource(String className, String source) Set the source code for the specified class. This will reset all compiled classes. | |
| Modifier and Type | Field and Description |
|---|---|
| private SecureClassLoader | |
| pack-priv Map | classObjectsByName
We use map because there can be nested, anonymous etc classes. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public ClassLoader | getClassLoader(JavaFileManager.
a location locationOverrides javax. Implements javax. Returns a class loader for loading plug-ins from the given package-oriented location. |
| public JavaFileObject | getJavaFileForOutput(JavaFileManager.
a package-oriented location location,the name of a class className, JavaFileObject.a file object to be used as hint for placement;
might be sibling)nullOverrides javax. Implements javax. Returns a file object for output representing the specified class of the specified kind in the given package-oriented location. |
| classLoader | back to summary |
|---|---|
| private SecureClassLoader classLoader | |
| classObjectsByName | back to summary |
|---|---|
| pack-priv Map<String, SourceCompiler. We use map because there can be nested, anonymous etc classes. | |
| ClassFileManager | back to summary |
|---|---|
| public ClassFileManager(StandardJavaFileManager standardManager) | |
| getClassLoader | back to summary |
|---|---|
| public ClassLoader getClassLoader(JavaFileManager. Overrides javax. Implements javax. Doc from javax. Returns a class loader for loading plug-ins from the given
package-oriented location.
For example, to load annotation processors,
a compiler will request a class loader for the
| |
| getJavaFileForOutput | back to summary |
|---|---|
| public JavaFileObject getJavaFileForOutput(JavaFileManager. Overrides javax. Implements javax. Doc from javax. Returns a file object for output representing the specified class of the specified kind in the given package-oriented location. Optionally, this file manager might consider the sibling as a hint for where to place the output. The exact semantics of this hint is unspecified. The JDK compiler, javac, for example, will place class files in the same directories as originating source files unless a class file output directory is provided. To facilitate this behavior, javac might provide the originating source file as sibling when calling this method.
| |
| Modifier and Type | Field and Description |
|---|---|
| private static final Throwable | |
| private static final Object |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static Class |
| INIT_FAIL_EXCEPTION | back to summary |
|---|---|
| private static final Throwable INIT_FAIL_EXCEPTION | |
| LOADER | back to summary |
|---|---|
| private static final Object LOADER | |
| GroovyCompiler | back to summary |
|---|---|
| private GroovyCompiler() | |
| parseClass | back to summary |
|---|---|
| public static Class | |
| Modifier and Type | Field and Description |
|---|---|
| private final ByteArrayOutputStream |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public byte[] | |
| public OutputStream | openOutputStream()
Overrides javax. Implements javax. Returns an OutputStream for this file object. |
| out | back to summary |
|---|---|
| private final ByteArrayOutputStream out | |
| JavaClassObject | back to summary |
|---|---|
| public JavaClassObject(String name, JavaFileObject. | |
| getBytes | back to summary |
|---|---|
| public byte[] getBytes() | |
| openOutputStream | back to summary |
|---|---|
| public OutputStream openOutputStream() throws IOException Overrides javax. Implements javax. Doc from javax. Returns an OutputStream for this file object.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public CharSequence | getCharContent(boolean
ignore encoding errors if true ignoreEncodingErrors)Overrides javax. Implements javax. Returns the character content of this file object, if available. |
| sourceCode | back to summary |
|---|---|
| private final String sourceCode | |
| StringJavaFileObject | back to summary |
|---|---|
| public StringJavaFileObject(String className, String sourceCode) | |
| getCharContent | back to summary |
|---|---|
| public CharSequence getCharContent(boolean ignoreEncodingErrors) Overrides javax. Implements javax. Doc from javax. Returns the character content of this file object, if available.
Any byte that cannot be decoded will be replaced by the default
translation character. In addition, a diagnostic may be
reported unless
| |