harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r409380 - in /incubator/harmony/enhanced/classlib/trunk/modules/tools: ./ META-INF/ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/harmony/ src/main/java/org/apache/harmony/tools/ src/mai...
Date Thu, 25 May 2006 12:47:53 GMT
Author: tellison
Date: Thu May 25 05:47:52 2006
New Revision: 409380

URL: http://svn.apache.org/viewvc?rev=409380&view=rev
Log: (empty)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/tools/.project   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/MANIFEST.MF
    incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java
  (with props)

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath Thu May 25 05:47:52
2006
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/tools/.classpath
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/.project
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/.project?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/.project (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/.project Thu May 25 05:47:52 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>tools</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/tools/.project
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/MANIFEST.MF?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/MANIFEST.MF (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/META-INF/MANIFEST.MF Thu May 25
05:47:52 2006
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Harmony Tools
+Bundle-SymbolicName: org.apache.harmony.tools
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Eclipse-JREBundle: true
+Import-Package: java.io,
+ java.lang,
+ java.lang.reflect,
+ java.net,
+ java.nio.charset,
+ java.security
+Export-Package: org.apache.harmony.tools.javac

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties Thu May 25 05:47:52
2006
@@ -0,0 +1,4 @@
+source.. = src/main/java/
+output.. = bin/
+bin.includes = META-INF/,\
+               .

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/tools/build.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java
Thu May 25 05:47:52 2006
@@ -0,0 +1,173 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tools.javac;
+
+import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+/**
+ * A proxy to the Java source code compiler itself.
+ */
+class Compiler {
+
+    /* A default encoding for console messages */
+    static String CONSOLE_ENCODING = System.getProperty("console.encoding",
+            "ISO8859_1");
+
+    /* FIXME: Hard-coded for now, the name of the ECJ JAR file */
+    static final String ECJ_JAR_FILE = "ecj_3.2RC5.jar";
+
+    /* The name of the ECJ compiler class */
+    static final String MAIN_CLASS_NAME = "org.eclipse.jdt.internal.compiler.batch.Main";
+
+    /*
+     * Invokes the compiler with the given command-line arguments. The supported
+     * arguments can be determined form the usage mesage.
+     */
+    public static void main(String[] args) {
+        Compiler myself = new Compiler();
+        myself.initialize();
+        // If there is a problem invoking the method, simply dump the trace for
+        // now
+        try {
+            myself.staticMainMth.invoke(myself.mainInst, new Object[] { args });
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        }
+    }
+
+    // Reference to ECJ 'Main' compiler class.
+    Class ecjCompilerClass;
+
+    // An instance of the ECJ compiler
+    Object mainInst;
+
+    // The Main#printUsage() method.
+    Method printUsageMth;
+
+    // The static Main#main(string[]) method on the ECJ compiler
+    Method staticMainMth;
+
+    /**
+     * Default constructor. Returns a new initialized instance of the Java
+     * compiler.
+     */
+    public Compiler() {
+        super();
+        initialize();
+    }
+
+    /*
+     * Initialize our local variables. Called during type construction.
+     */
+    protected void initialize() {
+        if (!new File(ECJ_JAR_FILE).exists()) {
+            System.err.println("javac requires the compiler jar \""
+                    + ECJ_JAR_FILE + "\" to run");
+        }
+        try {
+            initializeMainClass();
+            initializeInstance();
+            initializeMethods();
+        } catch (Exception e) {
+            // If there is a problem we log it to the console
+            e.printStackTrace();
+        }
+    }
+
+    /*
+     * Defines the local instance of the ECJ compiler
+     */
+    protected void initializeInstance() throws SecurityException,
+            NoSuchMethodException, IllegalArgumentException,
+            InstantiationException, IllegalAccessException,
+            InvocationTargetException {
+
+        // Set up reasonable defaults for the messages
+        OutputStreamWriter osw;
+        OutputStreamWriter esw;
+        try {
+            osw = new OutputStreamWriter(System.out, CONSOLE_ENCODING);
+            esw = new OutputStreamWriter(System.err, CONSOLE_ENCODING);
+        } catch (UnsupportedEncodingException e) {
+            osw = new OutputStreamWriter(System.out);
+            esw = new OutputStreamWriter(System.err);
+        }
+        PrintWriter outWriter = new PrintWriter(osw);
+        PrintWriter errWriter = new PrintWriter(esw);
+
+        // Create a new instance of the compiler
+        Constructor ctor = ecjCompilerClass.getConstructor(new Class[] {
+                PrintWriter.class, PrintWriter.class, Boolean.TYPE });
+
+        mainInst = ctor.newInstance(new Object[] { outWriter, errWriter,
+                Boolean.TRUE });
+    }
+
+    /*
+     * Defines the compiler class from the ECJ jar file
+     */
+    protected void initializeMainClass() throws ClassNotFoundException,
+            SecurityException, NoSuchMethodException, MalformedURLException,
+            IllegalArgumentException, InstantiationException,
+            IllegalAccessException, InvocationTargetException {
+
+        // Load the ECJ main class
+        URL ecjURL = new URL("file:" + ECJ_JAR_FILE);
+        URLClassLoader loader = new URLClassLoader(new URL[] { ecjURL });
+        ecjCompilerClass = loader.loadClass(MAIN_CLASS_NAME);
+    }
+
+    /*
+     * Initialize our local references to compiler methods we may wish to
+     * invoke.
+     */
+    protected void initializeMethods() throws SecurityException,
+            NoSuchMethodException {
+        staticMainMth = ecjCompilerClass.getMethod("main",
+                new Class[] { String[].class });
+        printUsageMth = ecjCompilerClass.getMethod("printUsage", null);
+    }
+
+    /**
+     * Prints the compiler usage message out on the console.
+     */
+    public void printUsage() {
+        // If there is a problem invoking the method, simply dump the trace for
+        // now
+        try {
+            printUsageMth.invoke(mainInst, null);
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        } catch (InvocationTargetException e) {
+            e.printStackTrace();
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Compiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java?rev=409380&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java
Thu May 25 05:47:52 2006
@@ -0,0 +1,58 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tools.javac;
+
+
+/**
+ * This is the entry point for the javac tool.
+ */
+public final class Main {
+
+    public static void main(String[] args) {
+
+        /* Give me something to do */
+        if (args.length == 0) {
+            new Compiler().printUsage();
+            return;
+        }
+
+        /* Add in the base class library code to compile against */
+        String[] newArgs = addBootclasspath(args);
+
+        /* Invoke the compiler */
+        Compiler.main(newArgs);
+    }
+
+    /**
+     * Default constructor.
+     */
+    public Main() {
+        super();
+    }
+
+    /*
+     * Set up the compiler option to compile against the running JRE class
+     * libraries.
+     */
+    public static String[] addBootclasspath(String[] args) {
+        String[] result = new String[args.length + 2];
+        System.arraycopy(args, 0, result, 0, args.length);
+        result[args.length] = "-classpath";
+        result[args.length + 1] = System.getProperty(
+                "com.ibm.oti.system.class.path", ".");
+        return result;
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/tools/src/main/java/org/apache/harmony/tools/javac/Main.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message