From a764e59e1d3a8e330f0d484fdb26b35ca3f0b2e4 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Sat, 22 Mar 2008 02:15:12 +0000 Subject: bringing pdj-0.8.3 into the main branch svn path=/trunk/externals/loaders/pdj/; revision=9621 --- src/java/com/e1/pdj/PDJClassLoader.java | 206 ++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 src/java/com/e1/pdj/PDJClassLoader.java (limited to 'src/java/com/e1/pdj/PDJClassLoader.java') diff --git a/src/java/com/e1/pdj/PDJClassLoader.java b/src/java/com/e1/pdj/PDJClassLoader.java new file mode 100644 index 0000000..ee54e71 --- /dev/null +++ b/src/java/com/e1/pdj/PDJClassLoader.java @@ -0,0 +1,206 @@ +package com.e1.pdj; + +import java.net.URLClassLoader; +import java.net.*; +import java.util.*; +import java.io.*; + +import com.cycling74.max.MaxSystem; + +public class PDJClassLoader extends URLClassLoader { + /** The folder where the class (and java files) are */ + static File fclasses; + + /** if this is set to true, all classloader operation will be logged */ + static boolean verboseCL = false; + + static private PDJClassLoader instance; + + static { + String prop = System.getProperty("pdj.classes-dir"); + + if ( prop == null ) { + fclasses = new File(System.getProperty("pdj.home") + "/classes"); + } else { + fclasses = new File(prop); + } + instance = new PDJClassLoader(); + + verboseCL = PDJSystem.isSystemPropertyTrue("pdj.verbose-classloader"); + } + + static public PDJClassLoader getInstance() { + return instance; + } + + public PDJClassLoader() { + super(resolvClasspath()); + } + + private static void findJars(File f, Collection v) throws MalformedURLException { + File files[] = f.listFiles(); + + for(int i = 0;i classFile.lastModified() ) { + compileClass(javaFile); + } else { + if ( verboseCL ) + MaxSystem.post("class: " + name + " is already compiled and younger than the source .java file"); + } + } else { + compileClass(javaFile); + } + } + + resetClassloader(); + + try { + return instance.loadClass(name); + } catch (ClassNotFoundException e) { + throw new PDJClassLoaderException(e); + } + } + + protected static void compileClass(File javaFile) throws PDJClassLoaderException { + String str_compiler = System.getProperty("pdj.compiler"); + GenericCompiler compiler = null; + + if ( str_compiler.equals("jikes") ) { + compiler = new JikesCompiler(); + } else { + if ( !str_compiler.equals("javac") ) { + System.err.println("pdj: unknown compiler:" + str_compiler + ", using javac."); + } + compiler = new JavacCompiler(); + } + compiler.javaFile = javaFile; + compiler.compileClass(); + } +} -- cgit v1.2.1