summaryrefslogtreecommitdiffstats
path: root/loadtime
diff options
context:
space:
mode:
authoravasseur <avasseur>2005-07-04 14:42:10 +0000
committeravasseur <avasseur>2005-07-04 14:42:10 +0000
commitfef895a7c89109c948ce356cdb24fc6aba2ebf1e (patch)
treeefb42dbdef8f58f194de809b9f17635f5add6d8e /loadtime
parent754466b993b196263c7b378499dc427f37368f2d (diff)
downloadaspectj-fef895a7c89109c948ce356cdb24fc6aba2ebf1e.tar.gz
aspectj-fef895a7c89109c948ce356cdb24fc6aba2ebf1e.zip
JRockit agent for LTW with 1.3/1.4 + update in doc
Diffstat (limited to 'loadtime')
-rw-r--r--loadtime/.classpath4
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/JRockitAgent.java77
2 files changed, 81 insertions, 0 deletions
diff --git a/loadtime/.classpath b/loadtime/.classpath
index fa9d32371..47982eb80 100644
--- a/loadtime/.classpath
+++ b/loadtime/.classpath
@@ -28,6 +28,10 @@
<attributes>
</attributes>
</classpathentry>
+ <classpathentry kind="lib" path="/lib/ext/jrockit/managementapi-jrockit81.jar">
+ <attributes>
+ </attributes>
+ </classpathentry>
<classpathentry sourcepath="/lib/junit/junit-src.jar" kind="lib" path="/lib/junit/junit.jar">
<attributes>
</attributes>
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/JRockitAgent.java b/loadtime/src/org/aspectj/weaver/loadtime/JRockitAgent.java
new file mode 100644
index 000000000..9b5191f2b
--- /dev/null
+++ b/loadtime/src/org/aspectj/weaver/loadtime/JRockitAgent.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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 (derivative from AspectWerkz)
+ *******************************************************************************/
+package org.aspectj.weaver.loadtime;
+
+import com.bea.jvm.JVMFactory;
+import com.jrockit.management.rmp.RmpSocketListener;
+
+/**
+ * JRockit (tested with 7SP4 and 8.1) preprocessor Adapter based on JMAPI <p/>JRockit has a low
+ * level API for hooking ClassPreProcessor, allowing the use of online weaving at full speed.
+ * Moreover, JRockit does not allow java.lang.ClassLoader overriding thru -Xbootclasspath/p option.
+ * <p/>The ClassPreProcessor
+ * implementation and all third party jars CAN reside in the standard classpath. <p/>The command
+ * line will look like:
+ * <code>"%JAVA_COMMAND%" -Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent -cp ...</code>
+ * Note: there can be some NoClassDefFoundError due to classpath limitation - as described in
+ * http://edocs.bea.com/wls/docs81/adminguide/winservice.html <p/>In order to use the BEA JRockit
+ * management server (for further connection of management console or runtime analyzer), the regular
+ * option -Xmanagement will not have any effect prior to JRockit 8.1 SP2. Instead, use <code>-Dmanagement</code>.
+ *
+ * @author <a href="mailto:alex AT gnilux DOT com">Alexandre Vasseur</a>
+ */
+public class JRockitAgent implements com.bea.jvm.ClassPreProcessor {
+
+ /**
+ * Concrete preprocessor
+ */
+ private final static ClassPreProcessor s_preProcessor;
+
+ private static boolean START_RMP_SERVER = false;
+
+ static {
+ START_RMP_SERVER = System.getProperties().containsKey("management");
+ try {
+ s_preProcessor = new Aj();
+ s_preProcessor.initialize();
+ } catch (Exception e) {
+ throw new ExceptionInInitializerError("could not initialize JRockitAgent preprocessor due to: " + e.toString());
+ }
+ }
+
+ /**
+ * The JMAPI ClassPreProcessor must be self registrating
+ */
+ public JRockitAgent() {
+ if (START_RMP_SERVER) {
+ // the management server will be spawned in a new thread
+ RmpSocketListener management = new RmpSocketListener();
+ }
+ JVMFactory.getJVM().getClassLibrary().setClassPreProcessor(this);
+ }
+
+ /**
+ * Weave a class
+ *
+ * @param caller classloader
+ * @param name of the class to weave
+ * @param bytecode original
+ * @return bytecode weaved
+ */
+ public byte[] preProcess(ClassLoader caller, String name, byte[] bytecode) {
+ if (caller == null || caller.getParent() == null) {
+ return bytecode;
+ } else {
+ return s_preProcessor.preProcess(name, bytecode, caller);
+ }
+ }
+} \ No newline at end of file