14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.test.lib; 25 26 import java.io.ByteArrayOutputStream; 27 import java.io.IOException; 28 import java.io.OutputStream; 29 30 import java.net.URI; 31 import java.util.Arrays; 32 33 import javax.tools.ForwardingJavaFileManager; 34 import javax.tools.ForwardingJavaFileManager; 35 import javax.tools.FileObject; 36 import javax.tools.JavaCompiler; 37 import javax.tools.JavaCompiler.CompilationTask; 38 import javax.tools.JavaFileManager; 39 import javax.tools.JavaFileObject; 40 import javax.tools.JavaFileObject.Kind; 41 import javax.tools.SimpleJavaFileObject; 42 import javax.tools.ToolProvider; 43 44 /** 45 * {@code InMemoryJavaCompiler} can be used for compiling a {@link 46 * CharSequence} to a {@code byte[]}. 47 * 48 * The compiler will not use the file system at all, instead using a {@link 49 * ByteArrayOutputStream} for storing the byte code. For the source code, any 50 * kind of {@link CharSequence} can be used, e.g. {@link String}, {@link 51 * StringBuffer} or {@link StringBuilder}. 52 * 53 * The {@code InMemoryCompiler} can easily be used together with a {@code 54 * ByteClassLoader} to easily compile and load source code in a {@link String}: 55 * 56 * <pre> 57 * {@code 58 * import jdk.test.lib.InMemoryJavaCompiler; | 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 package jdk.test.lib; 25 26 import java.io.ByteArrayOutputStream; 27 import java.io.IOException; 28 import java.io.OutputStream; 29 30 import java.net.URI; 31 import java.util.Arrays; 32 33 import javax.tools.ForwardingJavaFileManager; 34 import javax.tools.FileObject; 35 import javax.tools.JavaCompiler; 36 import javax.tools.JavaCompiler.CompilationTask; 37 import javax.tools.JavaFileObject; 38 import javax.tools.JavaFileObject.Kind; 39 import javax.tools.SimpleJavaFileObject; 40 import javax.tools.ToolProvider; 41 42 /** 43 * {@code InMemoryJavaCompiler} can be used for compiling a {@link 44 * CharSequence} to a {@code byte[]}. 45 * 46 * The compiler will not use the file system at all, instead using a {@link 47 * ByteArrayOutputStream} for storing the byte code. For the source code, any 48 * kind of {@link CharSequence} can be used, e.g. {@link String}, {@link 49 * StringBuffer} or {@link StringBuilder}. 50 * 51 * The {@code InMemoryCompiler} can easily be used together with a {@code 52 * ByteClassLoader} to easily compile and load source code in a {@link String}: 53 * 54 * <pre> 55 * {@code 56 * import jdk.test.lib.InMemoryJavaCompiler; |