From fef895a7c89109c948ce356cdb24fc6aba2ebf1e Mon Sep 17 00:00:00 2001 From: avasseur Date: Mon, 4 Jul 2005 14:42:10 +0000 Subject: [PATCH] JRockit agent for LTW with 1.3/1.4 + update in doc --- docs/adk15ProgGuideDB/ltw.xml | 57 ++++++------- lib/ext/jrockit/LICENSE.TXT | 8 ++ lib/ext/jrockit/managementapi-jrockit81.jar | Bin 0 -> 7796 bytes loadtime/.classpath | 4 + .../aspectj/weaver/loadtime/JRockitAgent.java | 77 ++++++++++++++++++ 5 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 lib/ext/jrockit/LICENSE.TXT create mode 100644 lib/ext/jrockit/managementapi-jrockit81.jar create mode 100644 loadtime/src/org/aspectj/weaver/loadtime/JRockitAgent.java diff --git a/docs/adk15ProgGuideDB/ltw.xml b/docs/adk15ProgGuideDB/ltw.xml index 8b6f027bb..e822a5d20 100644 --- a/docs/adk15ProgGuideDB/ltw.xml +++ b/docs/adk15ProgGuideDB/ltw.xml @@ -74,7 +74,7 @@ Enabling Load-time Weaving - AspectJ 5 supports three different ways of enabling load-time weaving for + AspectJ 5 supports several different ways of enabling load-time weaving for an application: agents, a command-line launch script, and a set of interfaces for integration of AspectJ load-time weaving in custom environments. @@ -83,30 +83,31 @@ AspectJ 5 ships with a number of load-time weaving agents that enable load-time weaving. These agents and their configuration - are execution environment dependent. - Using Java 5 for example, you can specify the "-javaagent" option - to the JVM. Configuration for the supported environments is discussed - later in this chapter. AspectJ 5 - has several agents including those that use JVMTI, and the - JRockit MAPI. - - - - Command line - - - AspectJ includes a script "aj" that allows programs executed at - the command line to take advantage of load-time weaving. - The script is customized when AspectJ is installed depending on the chosen - JDK. For example, for JDK 1.4 the script uses the - -Djava.system.class.loader system property to replace - the system class loader with a weaving class loader allowing classes - loaded from the CLASSPATH to be woven. - For JDK 1.5 the JVMTI weaving agent is used allowing classes loaded by all - class loaders to be woven. Versions of the JDK prior to 1.3 are not - supported by the "aj" mechanism. + are execution environment dependent. Configuration for the supported environments is discussed + later in this chapter.
+ Using Java 5 JVMTI you can specify the -javaagent:pathto/aspectjweaver.jar option + to the JVM.
+ Using BEA JRockit and Java 1.3/1.4, the very same behavior can be obtained using BEA JRockit JMAPI features with + the -Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent +
+ + + + + + + + + + + + + + + + Custom Integration @@ -114,7 +115,7 @@ to instantiate a weaver and weave classes after loading and before defining them in the JVM. This enables load-time weaving to be supported in environments where no weaving agent is available. It also allows the - user to explicity restrict by class loader which classes can be woven. + user to explicity restrict by class loader which classes can be woven. @@ -359,17 +360,17 @@ Supported Agents JVMTI - When using JDK 1.5 the JVMTI agent can be used by starting the JVM with the + When using Java 5 the JVMTI agent can be used by starting the JVM with the following option (adapt according to the path to aspectjweaver.jar): - JRockit + JRockit with Java 1.3/1.4 (use JVMTI on Java 5) The JRockit agent is configured with the following JVM option: diff --git a/lib/ext/jrockit/LICENSE.TXT b/lib/ext/jrockit/LICENSE.TXT new file mode 100644 index 000000000..6bbc97c40 --- /dev/null +++ b/lib/ext/jrockit/LICENSE.TXT @@ -0,0 +1,8 @@ +The managementapi-jrockit81.jar jar file in this folder is an excerpt of the BEA JRockit Management API +as per JRockit 8.1 (Java 1.4) (supports also for JRockit 7 ie Java 1.3). + +It contains only the class file needed at build time for AspectJ +and must not be used by the end-user. + +http://www.jrockit.com +http://www.bea.com \ No newline at end of file diff --git a/lib/ext/jrockit/managementapi-jrockit81.jar b/lib/ext/jrockit/managementapi-jrockit81.jar new file mode 100644 index 0000000000000000000000000000000000000000..f95129592fa57ea1733ec376eb1fbbbb983d16b7 GIT binary patch literal 7796 zcmaJ`1z1#D7ah8#8v#MOJEZfG5<@AdFbrJ|-4Y`yAf1ZREij~jbO?fkBM2%f2uKTz zfc!J!`{nWU?fEWTzBzl{ea=~Tv(MUkS{Ru40F*tjALsvZ^YaHD^0$sEP?1kVS4}_< zIgA2;i~L+1Msa?aj-sxHnyMj?Uq@|MXJ}Aci;sVlNQ;kqcxa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+{k|4yP8bNw&;38cnye!2gZ`7c6U%*Vf={AvCP^&i<;PYVl4 RJ^+9W`B_Ki7|0I}{13dBUDN;o literal 0 HcmV?d00001 diff --git a/loadtime/.classpath b/loadtime/.classpath index fa9d32371..47982eb80 100644 --- a/loadtime/.classpath +++ b/loadtime/.classpath @@ -28,6 +28,10 @@ + + + + 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

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. + *

The ClassPreProcessor + * implementation and all third party jars CAN reside in the standard classpath.

The command + * line will look like: + * "%JAVA_COMMAND%" -Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent -cp ... + * Note: there can be some NoClassDefFoundError due to classpath limitation - as described in + * http://edocs.bea.com/wls/docs81/adminguide/winservice.html

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 -Dmanagement. + * + * @author Alexandre Vasseur + */ +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 -- 2.39.5