]> source.dussan.org Git - aspectj.git/commitdiff
src -> java5-src; note test target runs AsmModuleTests, not Loadtime5ModuleTests...
authorwisberg <wisberg>
Wed, 11 May 2005 09:33:34 +0000 (09:33 +0000)
committerwisberg <wisberg>
Wed, 11 May 2005 09:33:34 +0000 (09:33 +0000)
loadtime5/build.xml
loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java [new file with mode: 0644]
loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java [new file with mode: 0644]
loadtime5/java5-testsrc/Loadtime515ModuleTests.java [new file with mode: 0644]
loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java [new file with mode: 0644]
loadtime5/newbuild.xml [new file with mode: 0644]
loadtime5/src/org/aspectj/weaver/loadtime/Agent.java [deleted file]
loadtime5/src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java [deleted file]
loadtime5/testsrc/Loadtime5ModuleTests.java [new file with mode: 0644]

index 97a1e2d99f40222ece939e980d20a9e352e0e461..41c07c1f1b78c9c52559a8ca8f2b4d429c6a206b 100644 (file)
@@ -28,7 +28,7 @@
         <!-- FIXME: we override compile due to use of 1.5 -->
         <mkdir dir="${basedir}/bin"/>
         <javac debug="on" destdir="${basedir}/bin" source="1.5" target="1.5">
-            <src path="${basedir}/src"/>
+            <src path="${basedir}/java5-src"/>
             <classpath refid="loadtime5.src.path"/>
         </javac>
     </target>
diff --git a/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java b/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java
new file mode 100644 (file)
index 0000000..bb34898
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.loadtime;
+
+import java.lang.instrument.Instrumentation;
+import java.lang.instrument.ClassFileTransformer;
+
+/**
+ * Java 1.5 preMain agent to hook in the class pre processor
+ * Can be used with -javaagent:aspectjweaver.jar
+ *
+ * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
+ */
+public class Agent {
+
+    /**
+     * The instrumentation instance
+     */
+    private static Instrumentation s_instrumentation;
+
+    /**
+     * The ClassFileTransformer wrapping the weaver
+     */
+    private static ClassFileTransformer s_transformer = new ClassPreProcessorAgentAdapter();
+
+    /**
+     * JSR-163 preMain Agent entry method
+     *
+     * @param options
+     * @param instrumentation
+     */
+    public static void premain(String options, Instrumentation instrumentation) {
+        s_instrumentation = instrumentation;
+        s_instrumentation.addTransformer(s_transformer);
+    }
+
+    /**
+     * Returns the Instrumentation system level instance
+     */
+    public static Instrumentation getInstrumentation() {
+        if (s_instrumentation == null) {
+            throw new UnsupportedOperationException("Java 5 was not started with preMain -javaagent for AspectJ");
+        }
+        return s_instrumentation;
+    }
+
+}
diff --git a/loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java b/loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java
new file mode 100644 (file)
index 0000000..9e81bd1
--- /dev/null
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Alexandre Vasseur         initial implementation
+ *******************************************************************************/
+package org.aspectj.weaver.loadtime;
+
+import org.aspectj.weaver.loadtime.Aj;
+import org.aspectj.weaver.loadtime.ClassPreProcessor;
+
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.security.ProtectionDomain;
+
+/**
+ * Java 1.5 adapter for class pre processor
+ *
+ * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
+ */
+public class ClassPreProcessorAgentAdapter implements ClassFileTransformer {
+
+    /**
+     * Concrete preprocessor.
+     */
+    private static ClassPreProcessor s_preProcessor;
+
+    static {
+        try {
+            s_preProcessor = new Aj();
+            s_preProcessor.initialize();
+        } catch (Exception e) {
+            throw new ExceptionInInitializerError("could not initialize JSR163 preprocessor due to: " + e.toString());
+        }
+    }
+
+    /**
+     * Weaving delegation
+     *
+     * @param loader              the defining class loader
+     * @param className           the name of class beeing loaded
+     * @param classBeingRedefined when hotswap is called
+     * @param protectionDomain
+     * @param bytes               the bytecode before weaving
+     * @return the weaved bytecode
+     */
+    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
+                            ProtectionDomain protectionDomain, byte[] bytes) throws IllegalClassFormatException {
+        if (classBeingRedefined == null) {
+            return s_preProcessor.preProcess(className, bytes, loader);
+        } else {
+            //FIXME av for now we skip hotswap. We should think more about that
+            new Exception("AspectJ5 does not weave hotswapped class (" + className + ")").printStackTrace();
+            return bytes;
+        }
+    }
+
+}
diff --git a/loadtime5/java5-testsrc/Loadtime515ModuleTests.java b/loadtime5/java5-testsrc/Loadtime515ModuleTests.java
new file mode 100644 (file)
index 0000000..91d3aec
--- /dev/null
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: (See CVS logs)
+ * 
+ *******************************************************************************/
+
+import org.aspectj.weaver.loadtime.LoadtimeTests;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ */
+public class Loadtime515ModuleTests extends TestCase {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(Loadtime515ModuleTests.class.getName());
+        suite.addTestSuite(LoadtimeTests.class);
+        return suite;
+    }
+
+}
diff --git a/loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java b/loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java
new file mode 100644 (file)
index 0000000..f777b7f
--- /dev/null
@@ -0,0 +1,26 @@
+/* *******************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved. 
+ * This program and the accompanying materials are made available 
+ * under the terms of the Eclipse Public License v1.0 
+ * which accompanies this distribution and is available at 
+ * http://eclipse.org/legal/epl-v10.html 
+ *  
+ * Contributors: 
+ *     Wes Isberg       initial implementation 
+ * ******************************************************************/
+
+
+package org.aspectj.weaver.loadtime;
+
+import java.lang.instrument.Instrumentation;
+
+import junit.framework.TestCase;
+
+public class LoadtimeTests extends TestCase {
+
+    public void testPremain() throws Exception {            
+        Class[] parmTypes = {String.class, Instrumentation.class };
+        assertNotNull(Agent.class.getMethod("premain", parmTypes));
+    }
+}
diff --git a/loadtime5/newbuild.xml b/loadtime5/newbuild.xml
new file mode 100644 (file)
index 0000000..a2a3e62
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<!-- see ../build/*.html for explanation -->
+<project name="loadtime5" default="test" basedir=".">
+    <import file="${basedir}/../build/build.xml"/>  
+</project>
+
diff --git a/loadtime5/src/org/aspectj/weaver/loadtime/Agent.java b/loadtime5/src/org/aspectj/weaver/loadtime/Agent.java
deleted file mode 100644 (file)
index bb34898..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Alexandre Vasseur         initial implementation
- *******************************************************************************/
-package org.aspectj.weaver.loadtime;
-
-import java.lang.instrument.Instrumentation;
-import java.lang.instrument.ClassFileTransformer;
-
-/**
- * Java 1.5 preMain agent to hook in the class pre processor
- * Can be used with -javaagent:aspectjweaver.jar
- *
- * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
- */
-public class Agent {
-
-    /**
-     * The instrumentation instance
-     */
-    private static Instrumentation s_instrumentation;
-
-    /**
-     * The ClassFileTransformer wrapping the weaver
-     */
-    private static ClassFileTransformer s_transformer = new ClassPreProcessorAgentAdapter();
-
-    /**
-     * JSR-163 preMain Agent entry method
-     *
-     * @param options
-     * @param instrumentation
-     */
-    public static void premain(String options, Instrumentation instrumentation) {
-        s_instrumentation = instrumentation;
-        s_instrumentation.addTransformer(s_transformer);
-    }
-
-    /**
-     * Returns the Instrumentation system level instance
-     */
-    public static Instrumentation getInstrumentation() {
-        if (s_instrumentation == null) {
-            throw new UnsupportedOperationException("Java 5 was not started with preMain -javaagent for AspectJ");
-        }
-        return s_instrumentation;
-    }
-
-}
diff --git a/loadtime5/src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java b/loadtime5/src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java
deleted file mode 100644 (file)
index 9e81bd1..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *   Alexandre Vasseur         initial implementation
- *******************************************************************************/
-package org.aspectj.weaver.loadtime;
-
-import org.aspectj.weaver.loadtime.Aj;
-import org.aspectj.weaver.loadtime.ClassPreProcessor;
-
-import java.lang.instrument.ClassFileTransformer;
-import java.lang.instrument.IllegalClassFormatException;
-import java.security.ProtectionDomain;
-
-/**
- * Java 1.5 adapter for class pre processor
- *
- * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur</a>
- */
-public class ClassPreProcessorAgentAdapter implements ClassFileTransformer {
-
-    /**
-     * Concrete preprocessor.
-     */
-    private static ClassPreProcessor s_preProcessor;
-
-    static {
-        try {
-            s_preProcessor = new Aj();
-            s_preProcessor.initialize();
-        } catch (Exception e) {
-            throw new ExceptionInInitializerError("could not initialize JSR163 preprocessor due to: " + e.toString());
-        }
-    }
-
-    /**
-     * Weaving delegation
-     *
-     * @param loader              the defining class loader
-     * @param className           the name of class beeing loaded
-     * @param classBeingRedefined when hotswap is called
-     * @param protectionDomain
-     * @param bytes               the bytecode before weaving
-     * @return the weaved bytecode
-     */
-    public byte[] transform(ClassLoader loader, String className, Class<?> classBeingRedefined,
-                            ProtectionDomain protectionDomain, byte[] bytes) throws IllegalClassFormatException {
-        if (classBeingRedefined == null) {
-            return s_preProcessor.preProcess(className, bytes, loader);
-        } else {
-            //FIXME av for now we skip hotswap. We should think more about that
-            new Exception("AspectJ5 does not weave hotswapped class (" + className + ")").printStackTrace();
-            return bytes;
-        }
-    }
-
-}
diff --git a/loadtime5/testsrc/Loadtime5ModuleTests.java b/loadtime5/testsrc/Loadtime5ModuleTests.java
new file mode 100644 (file)
index 0000000..231c80d
--- /dev/null
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2005 Contributors.
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: (See CVS logs)
+ * 
+ *******************************************************************************/
+
+import org.aspectj.testing.util.TestUtil;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ */
+public class Loadtime5ModuleTests extends TestCase {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite(Loadtime5ModuleTests.class.getName());
+        TestUtil.loadTestsReflectively(suite, "Loadtime515ModuleTests", true);
+        return suite;
+    }
+    public static void main(String[] args) {
+        junit.textui.TestRunner.main(new String[] {Loadtime5ModuleTests.class.getName()});
+    }
+
+}