aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build/src/main/java/org/aspectj/internal/tools/build/Builder.properties2
-rw-r--r--docs/devGuideDB/ltw.xml138
-rw-r--r--lib/jrockit/LICENSE.TXT8
-rw-r--r--lib/jrockit/jrockit-src.zipbin2570 -> 0 bytes
-rw-r--r--lib/jrockit/jrockit.jarbin1969 -> 0 bytes
-rw-r--r--lib/jrockit/managementapi-jrockit81.jarbin7796 -> 0 bytes
-rw-r--r--libx/pom.xml10
-rw-r--r--loadtime/pom.xml8
-rw-r--r--loadtime/src/main/java/org/aspectj/weaver/loadtime/JRockitAgent.java84
-rw-r--r--loadtime/src/test/java/org/aspectj/bea/jvm/ClassLibraryImpl.java29
-rw-r--r--loadtime/src/test/java/org/aspectj/bea/jvm/JVMImpl.java24
-rw-r--r--loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java2
-rw-r--r--loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java228
-rw-r--r--run-all-junit-tests/pom.xml7
-rw-r--r--tests/ltw/java/net/URLClassLoader.java79
15 files changed, 94 insertions, 525 deletions
diff --git a/build/src/main/java/org/aspectj/internal/tools/build/Builder.properties b/build/src/main/java/org/aspectj/internal/tools/build/Builder.properties
index 3838514f4..64998977a 100644
--- a/build/src/main/java/org/aspectj/internal/tools/build/Builder.properties
+++ b/build/src/main/java/org/aspectj/internal/tools/build/Builder.properties
@@ -10,7 +10,7 @@ alias.org.aspectj.matcher.jar=org.aspectj.matcher-all.jar
# libraries to avoid bundling (IBM JRE different, etc.)
# see build/readme-build-module.html, Builder.SKIP_LIBRARIES
-skip.libraries=asm-3.1.jar,core.jar,graphics.jar,ant.jar,tools.jar,bcel-verifier.jar,asm-3.1.jar,junit.jar,xml-apis.jar,xercesImpl.jar,commons.jar,jrockit.jar
+skip.libraries=asm-3.1.jar,core.jar,graphics.jar,ant.jar,tools.jar,bcel-verifier.jar,asm-3.1.jar,junit.jar,xml-apis.jar,xercesImpl.jar,commons.jar
# Ant patterns to gather and omit resources
# files copied during module jar assembly
diff --git a/docs/devGuideDB/ltw.xml b/docs/devGuideDB/ltw.xml
index 3d8723662..bc5aac769 100644
--- a/docs/devGuideDB/ltw.xml
+++ b/docs/devGuideDB/ltw.xml
@@ -1,23 +1,23 @@
<chapter id="ltw" xreflabel="Load-Time Weaving">
<title>Load-Time Weaving</title>
-
+
<sect1 id="ltw-introduction">
<title>Introduction</title>
-
+
<para> The AspectJ weaver takes class files as input and produces class files as output.
The weaving process itself can take place at one of three different times: compile-time,
post-compile time, and load-time. The class files produced by the weaving process (and
hence the run-time behaviour of an application) are the same regardless of the approach
chosen. </para>
-
+
<itemizedlist>
<listitem> <para>Compile-time weaving is the simplest approach. When you have the source code
for an application, ajc will compile from source and produce woven class files as
output. The invocation of the weaver is integral to the ajc compilation process. The
- aspects themselves may be in source or binary form.
+ aspects themselves may be in source or binary form.
If the aspects are required for the affected classes to compile, then
you must weave at compile-time. Aspects are required, e.g., when they
- add members to a class and other classes being compiled reference the
+ add members to a class and other classes being compiled reference the
added members.
</para></listitem>
<listitem> <para>Post-compile weaving (also sometimes called binary weaving) is used to weave
@@ -29,32 +29,32 @@
one or more "weaving class loaders", either provided explicitly by the run-time
environment or enabled through a "weaving agent" are required. </para></listitem>
</itemizedlist>
-
+
<para> You may also hear the term "run-time weaving". We define this as the weaving of
classes that have already been defined to the JVM (without reloading those
classes). AspectJ 5 does not provide explicit support for run-time weaving although
simple coding patterns can support dynamically enabling and disabling advice in aspects. </para>
-
+
<sect2 id="weaving-class-files-more-than-once" xreflabel="weaving-class-files-more-than-once">
<title>Weaving class files more than once</title>
-
+
<para> As of AspectJ 5 aspects (code style or annotation style) and woven classes are
- reweavable by default. If you are developing AspectJ applications that are to be used
+ reweavable by default. If you are developing AspectJ applications that are to be used
in a load-time weaving environment with an older version of the compiler you
need to specify the <literal>-Xreweavable</literal> compiler option when building
them. This causes AspectJ to save additional state in the class files that is used
to support subsequent reweaving. </para>
</sect2>
</sect1>
-
+
<sect1 id="ltw-rules">
<title>Load-time Weaving Requirements</title>
-
+
<para> All load-time weaving is done in the context of a class loader, and hence the set of
aspects used for weaving and the types that can be woven are affected by the class
loader delegation model. This ensures that LTW complies with the Java 2 security model.
The following rules govern the interaction of load-time weaving with class loading: </para>
-
+
<orderedlist>
<listitem> <para>All aspects to be used for weaving must be defined to the weaver before any
types to be woven are loaded. This avoids types being "missed" by aspects added
@@ -66,19 +66,19 @@
may be extended.
</para></listitem>
<listitem><para>A class loader may only weave classes that it defines. It may not weave
- classes loaded by a delegate or parent class loader.</para></listitem>
+ classes loaded by a delegate or parent class loader.</para></listitem>
</orderedlist>
-
+
</sect1>
-
+
<sect1 id="ltw-configuration">
<title>Configuration</title>
<para>New in AspectJ 5 are a number of mechanisms to make load-time weaving
- easy to use. The load-time weaving mechanism is chosen through JVM startup options.
- Configuration files determine the set of aspects to be used for weaving and which
- types will be woven. Additional diagnostic options allow the user to debug the configuration and
+ easy to use. The load-time weaving mechanism is chosen through JVM startup options.
+ Configuration files determine the set of aspects to be used for weaving and which
+ types will be woven. Additional diagnostic options allow the user to debug the configuration and
weaving process. </para>
-
+
<sect2 id="enabling-load-time-weaving" xreflabel="enabling-load-time-weaving">
<title>Enabling Load-time Weaving</title>
<para> AspectJ 5 supports several ways of enabling load-time weaving for
@@ -88,15 +88,16 @@
<varlistentry>
<term>Agents</term>
<listitem>
- <para>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. Configuration for the supported environments is discussed
+ <para>AspectJ 5 ships with a load-time weaving agent that
+ enables load-time weaving. This agent and its configuration
+ is execution environment dependent. Configuration for the supported environments is discussed
later in this chapter.</para>
<para>
Using Java 5 JVMTI you can specify the <literal>-javaagent:pathto/aspectjweaver.jar</literal> option
to the JVM.</para><para>
- Using BEA JRockit and Java 1.3/1.4, the very same behavior can be obtained using BEA JRockit JMAPI features with
- the <literal>-Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent</literal>
+ Since AspectJ 1.9.7, the obsolete Oracle/BEA JRockit agent is no longer part of AspectJ.
+ JRockit JDK never supported Java versions higher than 1.6. Several JRockit JVM features are
+ now part of HotSpot and tools like Mission Control available for OpenJDK and Oracle JDK.
</para>
</listitem>
</varlistentry>
@@ -104,12 +105,12 @@
<term>Command-line wrapper scripts <literal>aj</literal></term>
<listitem>
<para>The <command>aj</command> command runs Java programs in Java 1.4 or
- later by setting up <literal>WeavingURLClassLoader</literal> as the
- system class loader.
+ later by setting up <literal>WeavingURLClassLoader</literal> as the
+ system class loader.
For more information, see <xref linkend="aj"/>.
</para>
<para>The <command>aj5</command> command runs Java programs in Java 5
- by using the <literal>-javaagent:pathto/aspectjweaver.jar</literal> option
+ by using the <literal>-javaagent:pathto/aspectjweaver.jar</literal> option
described above.
For more information, see <xref linkend="aj"/>.
</para>
@@ -132,10 +133,10 @@
</varlistentry>
</variablelist>
</sect2>
-
+
<sect2 id="configuring-load-time-weaving-with-aopxml-files" xreflabel="configuring-load-time-weaving-with-aopxml-files">
<title>Configuring Load-time Weaving with aop.xml files</title>
-
+
<para>The weaver is configured using one or more <literal>META-INF/aop.xml</literal>
files located on the class loader search path. Each file may declare a list of
aspects to be used for weaving, type patterns describing which types
@@ -187,16 +188,16 @@
<!-- Dump all types within the "com.foo.bar" package and sub-packages,
both before are after they are woven,
which can be used for byte-code generated at runtime
- <dump within="com.foo.bar..*" beforeandafter="true"/>
+ <dump within="com.foo.bar..*" beforeandafter="true"/>
</weaver>
</aspectj>
]]></programlisting>
-
+
<para>
- The DTD defining the format of this file is available here:
- http://www.eclipse.org/aspectj/dtd/aspectj.dtd.
+ The DTD defining the format of this file is available here:
+ http://www.eclipse.org/aspectj/dtd/aspectj.dtd.
</para>
<para>
An aop.xml file contains two key sections: <literal>aspects</literal> defines one
@@ -204,15 +205,15 @@
used in the weaving process; <literal>weaver</literal> defines weaver options and which
types should be woven.
</para>
-
+
<para>
- The simplest way to define an aspect to the weaver is to
- specify the fully-qualified name of the aspect type in an aspect element.
+ The simplest way to define an aspect to the weaver is to
+ specify the fully-qualified name of the aspect type in an aspect element.
You can also
declare (and define to the weaver) aspects inline in the aop.xml file.
This is done using the <literal>concrete-aspect</literal> element. A concrete-aspect
- declaration must provide a pointcut definition for every abstract
- pointcut in the abstract aspect it extends. This mechanism is a
+ declaration must provide a pointcut definition for every abstract
+ pointcut in the abstract aspect it extends. This mechanism is a
useful way of externalizing configuration for infrastructure and
auxiliary aspects where the pointcut definitions themselves can be
considered part of the configuration of the service.
@@ -229,15 +230,15 @@
and || are replaced by 'AND' and 'OR'.
</para>
<para>
- Note that <literal>include</literal> and <literal>exclude</literal> elements affect all aspects
- declared to the weaver including those in other aop.xml files. To help avoid unexpected
+ Note that <literal>include</literal> and <literal>exclude</literal> elements affect all aspects
+ declared to the weaver including those in other aop.xml files. To help avoid unexpected
behaviour a lint warning is issued
if an aspect is not declared as a result of of applying these filters.
Also note <literal>aspect</literal> and <literal>concrete-aspect</literal> elements
must be used to declare aspects to the weaver i.e. <literal>include</literal> and <literal>exclude</literal>
elements cannot be used find aspects on the class loader search path.
</para>
-
+
<para>
The <literal>weaver</literal> element is used to pass options to the weaver and to specify
the set of types that should be woven. If no include elements are specified
@@ -245,10 +246,10 @@
element can be used capture on disk byte-code of woven classes for diagnostic purposes both before,
in the case of those generated at runtime, and after the weaving process.
</para>
-
-
+
+
<para> When several configuration files are visible from a given weaving class loader
- their contents are conceptually merged.
+ their contents are conceptually merged.
The files are merged in the order they are
found on the search path (with a regular <literal>getResourceAsStream</literal> lookup)
according to the following rules: </para>
@@ -263,7 +264,7 @@
by any exclude statements. If there are no include statements then all non-excluded
aspects are included.</para></listitem>
<listitem> <para> The set of types to be woven are those types matched by at
- least one weaver <literal>include</literal> element and not matched by any
+ least one weaver <literal>include</literal> element and not matched by any
weaver <literal>exclude</literal> element. If there are no weaver include
statements then all non-excluded types are included.</para></listitem>
<listitem> <para> The weaver options are derived by taking the union of the
@@ -272,19 +273,19 @@
will be used.</para></listitem>
</itemizedlist>
- <para>It is not an error for the same aspect to be defined to the weaver in
- more than one visible <literal>META-INF/aop.xml</literal> file.
+ <para>It is not an error for the same aspect to be defined to the weaver in
+ more than one visible <literal>META-INF/aop.xml</literal> file.
However, if the same concrete aspect
is defined in more than one aop.xml file then an error will be issued.
- A concrete aspect
+ A concrete aspect
defined in this way will be used to weave types loaded by the
- class loader that loaded the aop.xml file in which it was defined.
+ class loader that loaded the aop.xml file in which it was defined.
</para>
-
+
<para> A <literal>META-INF/aop.xml</literal> can be generated by
- using either the <literal>-outxml</literal> or <literal>-outxmlfile</literal> options of the AspectJ compiler.
+ using either the <literal>-outxml</literal> or <literal>-outxmlfile</literal> options of the AspectJ compiler.
It will simply contain a (possibly empty) set of aspect elements; one for
- each abstract or concrete aspect defined.
+ each abstract or concrete aspect defined.
When used in conjuction with the <literal>-outjar</literal> option
a JAR is produced that can be used
with the <command>aj5</command> command or a load-time weaving environment.</para>
@@ -333,7 +334,7 @@
]]></programlisting>
<para>
This aspect (in either style) can be made concrete using <literal>META-INF/aop.xml</literal>.
- It defines the abstract pointcut <literal>scope()</literal>. When using this mechanism the
+ It defines the abstract pointcut <literal>scope()</literal>. When using this mechanism the
following rules apply:
<itemizedlist>
<listitem><para>The parent aspect must be abstract. It can be an @AspectJ or a
@@ -343,17 +344,17 @@
as illustrated in this sample, this means the method that hosts the pointcut must be abstract,
have no arguments, and return void.</para></listitem>
<listitem><para>The concrete aspect must implement all inherited abstract pointcuts.</para></listitem>
- <listitem><para>The concrete aspect may not implement methods so the abstract aspect it
+ <listitem><para>The concrete aspect may not implement methods so the abstract aspect it
extends may not contain any abstract methods.</para></listitem>
</itemizedlist>
</para>
-
+
<para>
<emphasis>A limitation of the implementation of this feature in AspectJ 1.5.0 is that aspects defined using
aop.xml are not exposed to the weaver. This means that they are not affected by advice and ITDs defined in
other aspects. Support for this capability will be considered in a future release.</emphasis>
</para>
-
+
<para>
If more complex aspect inheritance is required use regular aspect
inheritance instead of XML.
@@ -456,7 +457,7 @@
<entry>
<literal>-verbose</literal>
</entry>
- <entry>Issue informational messages about the weaving process. Messages issued while the weaver is being
+ <entry>Issue informational messages about the weaving process. Messages issued while the weaver is being
bootstrapped are accumulated until all options are parsed. If the messages are required to be output
immediately you can use the option <literal>-Daj.weaving.verbose=true</literal> on the JVM startup command line.
</entry>
@@ -466,11 +467,11 @@
<literal>-debug</literal>
</entry>
<entry>
- Issue a messages for each class passed to the weaver
- indicating whether it was woven, excluded or ignored.
+ Issue a messages for each class passed to the weaver
+ indicating whether it was woven, excluded or ignored.
Also issue messages for classes
defined during the weaving process such as around advice
- closures and concrete aspects defined in
+ closures and concrete aspects defined in
<literal>META-INF/aop.xml</literal>.
</entry>
</row>
@@ -542,7 +543,7 @@
The given value must be the full qualified class name of a class that implements the
<literal>org.aspectj.bridge.IMessageHandler</literal> interface
and is visible to the classloader with which the weaver being configured is associated.
- Exercise caution when packaging a custom message handler with an application that is to
+ Exercise caution when packaging a custom message handler with an application that is to
be woven. The handler (as well as classes on which it depends) cannot itself be woven
by the aspects that are declared to the same weaver.
</entry>
@@ -556,7 +557,7 @@
<sect1 id="ltw-specialcases">
<title>Special cases</title>
<para>
- The following classes are not exposed to the LTW infrastructure regardless of
+ The following classes are not exposed to the LTW infrastructure regardless of
the <literal>aop.xml</literal> file(s) used:
<itemizedlist>
<listitem> <para>All <literal>org.aspectj.*</literal> classes (and subpackages) - as those are needed by the infrastructure itself</para></listitem>
@@ -578,14 +579,14 @@
won't be handled as a warn (as during compile time) but as an info message.
</para>
</sect1>
-
+
<sect1 id="ltw-packaging">
<title>Runtime Requirements for Load-time Weaving</title>
<para> To use LTW the <literal>aspectjweaver.jar</literal> library must be added to the
classpath. This contains the AspectJ 5 runtime, weaver, weaving class loader and
weaving agents. It also contains the DTD for parsing XML weaving configuration files. </para>
</sect1>
-
+
<sect1 id="ltw-agents">
<title>Supported Agents</title>
<sect2 id="jvmti" xreflabel="jvmti">
@@ -598,10 +599,11 @@
</sect2>
<sect2 id="jrockit" xreflabel="jrockit">
<title>JRockit with Java 1.3/1.4 (use JVMTI on Java 5)</title>
- <para> The JRockit agent is configured with the following JVM option: </para>
- <programlisting><![CDATA[
- -Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent
- ]]></programlisting>
+ <para>
+ Since AspectJ 1.9.7, the obsolete Oracle/BEA JRockit agent is no longer part of AspectJ.
+ JRockit JDK never supported Java versions higher than 1.6. Several JRockit JVM features are
+ now part of HotSpot and tools like Mission Control available for OpenJDK and Oracle JDK.
+ </para>
</sect2>
</sect1>
</chapter>
diff --git a/lib/jrockit/LICENSE.TXT b/lib/jrockit/LICENSE.TXT
deleted file mode 100644
index 6bbc97c40..000000000
--- a/lib/jrockit/LICENSE.TXT
+++ /dev/null
@@ -1,8 +0,0 @@
-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/jrockit/jrockit-src.zip b/lib/jrockit/jrockit-src.zip
deleted file mode 100644
index dce223db8..000000000
--- a/lib/jrockit/jrockit-src.zip
+++ /dev/null
Binary files differ
diff --git a/lib/jrockit/jrockit.jar b/lib/jrockit/jrockit.jar
deleted file mode 100644
index 0395fceb0..000000000
--- a/lib/jrockit/jrockit.jar
+++ /dev/null
Binary files differ
diff --git a/lib/jrockit/managementapi-jrockit81.jar b/lib/jrockit/managementapi-jrockit81.jar
deleted file mode 100644
index f95129592..000000000
--- a/lib/jrockit/managementapi-jrockit81.jar
+++ /dev/null
Binary files differ
diff --git a/libx/pom.xml b/libx/pom.xml
index 8670f1a08..4df26b50a 100644
--- a/libx/pom.xml
+++ b/libx/pom.xml
@@ -215,16 +215,6 @@
<outputDirectory>asm</outputDirectory>
<destFileName>asm-${asm.version}.renamed-src.zip</destFileName>
</artifactItem>
-
- <!--
- How relevant is JRockit in 2021?
- https://en.wikipedia.org/wiki/JRockit
- https://www.oracle.com/java/jrockit.html
-
- There are only org.aspectj.weaver.loadtime.JRockitAgent + tests. If we would get rid of that class,
- all the rest and jrockit.jar could also go away.
- -->
-
<artifactItem>
<!-- Binary is identical to committed version in branch 'jdtcore-new' -->
<groupId>com.googlecode.jarjar</groupId>
diff --git a/loadtime/pom.xml b/loadtime/pom.xml
index d7333cd72..7c03455e5 100644
--- a/loadtime/pom.xml
+++ b/loadtime/pom.xml
@@ -66,14 +66,6 @@
<artifactId>xercesImpl</artifactId>
<version>${lib.ant.xerces.version}</version>
</dependency>
- <dependency>
- <groupId>jrockit</groupId>
- <artifactId>jrockit</artifactId>
- <version>1.0</version>
- <scope>system</scope>
- <systemPath>${project.basedir}/../lib/jrockit/jrockit.jar</systemPath>
- </dependency>
-
<dependency>
<!-- Identical to lib/ant/lib/ant.jar, a former system-scoped dependency -->
<groupId>ant</groupId>
diff --git a/loadtime/src/main/java/org/aspectj/weaver/loadtime/JRockitAgent.java b/loadtime/src/main/java/org/aspectj/weaver/loadtime/JRockitAgent.java
deleted file mode 100644
index 56ad0e958..000000000
--- a/loadtime/src/main/java/org/aspectj/weaver/loadtime/JRockitAgent.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.weaver.loadtime;
-
-import java.util.Stack;
-
-import com.bea.jvm.ClassLibrary;
-import com.bea.jvm.JVMFactory;
-
-/**
- * BEA JRocket JMAPI agent.
- *
- * Use "-Xmanagement:class=org.aspectj.weaver.loadtime.JRockitAgent"
- */
-public class JRockitAgent implements com.bea.jvm.ClassPreProcessor {
-
- private ClassPreProcessor preProcessor;
-
- /*
- * This is used to implement the recursion protection offered by JVMTI but not by JRockit JMAPI. I we are called to preProcess a
- * class while already preProcessing another we will return immediately
- */
- private static ThreadLocalStack stack = new ThreadLocalStack();
-
- public JRockitAgent() {
- this.preProcessor = new Aj();
-
- ClassLibrary cl = JVMFactory.getJVM().getClassLibrary();
- cl.setClassPreProcessor(this);
- }
-
- public byte[] preProcess(ClassLoader loader, String className, byte[] bytes) {
- byte[] newBytes = bytes;
-
- if (stack.empty()) {
- stack.push(className);
- newBytes = preProcessor.preProcess(className, bytes, loader, null);
- stack.pop();
- }
-
- return newBytes;
- }
-
- private static class ThreadLocalStack extends ThreadLocal {
-
- public boolean empty() {
- Stack stack = (Stack) get();
- return stack.empty();
- }
-
- public Object peek() {
- Object obj = null;
- Stack stack = (Stack) get();
- if (!stack.empty())
- obj = stack.peek();
- return obj;
- }
-
- public void push(Object obj) {
- Stack stack = (Stack) get();
- if (!stack.empty() && obj == stack.peek())
- throw new RuntimeException(obj.toString());
- stack.push(obj);
- }
-
- public Object pop() {
- Stack stack = (Stack) get();
- return stack.pop();
- }
-
- protected Object initialValue() {
- return new Stack();
- }
- }
-
-}
diff --git a/loadtime/src/test/java/org/aspectj/bea/jvm/ClassLibraryImpl.java b/loadtime/src/test/java/org/aspectj/bea/jvm/ClassLibraryImpl.java
deleted file mode 100644
index 8b4c58446..000000000
--- a/loadtime/src/test/java/org/aspectj/bea/jvm/ClassLibraryImpl.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.bea.jvm;
-
-import com.bea.jvm.ClassLibrary;
-import com.bea.jvm.ClassPreProcessor;
-import com.bea.jvm.NotAvailableException;
-
-public class ClassLibraryImpl implements ClassLibrary {
-
- private ClassPreProcessor preProcessor;
-
- public ClassPreProcessor getClassPreProcessor() throws NotAvailableException {
- return preProcessor;
- }
-
- public void setClassPreProcessor(ClassPreProcessor classPreProcessor) {
- this.preProcessor = classPreProcessor;
- }
-
-}
diff --git a/loadtime/src/test/java/org/aspectj/bea/jvm/JVMImpl.java b/loadtime/src/test/java/org/aspectj/bea/jvm/JVMImpl.java
deleted file mode 100644
index caae32e6f..000000000
--- a/loadtime/src/test/java/org/aspectj/bea/jvm/JVMImpl.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.bea.jvm;
-
-import com.bea.jvm.ClassLibrary;
-import com.bea.jvm.JVM;
-
-public class JVMImpl implements JVM {
-
- private ClassLibrary libarary = new ClassLibraryImpl();
-
- public ClassLibrary getClassLibrary() {
- return libarary;
- }
-
-}
diff --git a/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java b/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java
index 9d365ffab..352156f82 100644
--- a/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java
+++ b/loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java
@@ -10,7 +10,6 @@ package org.aspectj.loadtime;
import org.aspectj.weaver.loadtime.AjTest;
import org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptorTest;
-import org.aspectj.weaver.loadtime.JRockitAgentTest;
import org.aspectj.weaver.loadtime.LoadtimeTest;
import org.aspectj.weaver.loadtime.WeavingContextTest;
import org.aspectj.weaver.loadtime.WeavingURLClassLoaderTest;
@@ -32,7 +31,6 @@ public class LoadtimeModuleTests extends TestCase {
suite.addTestSuite(DocumentParserTest.class);
suite.addTestSuite(AjTest.class);
suite.addTestSuite(ClassLoaderWeavingAdaptorTest.class);
- suite.addTestSuite(JRockitAgentTest.class);
suite.addTestSuite(LoadtimeTest.class);
suite.addTestSuite(WeavingContextTest.class);
suite.addTestSuite(WeavingURLClassLoaderTest.class);
diff --git a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java b/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java
deleted file mode 100644
index 7f9d235d0..000000000
--- a/loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.weaver.loadtime;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-
-import com.bea.jvm.ClassPreProcessor;
-import com.bea.jvm.JVMFactory;
-
-import junit.framework.TestCase;
-
-public class JRockitAgentTest extends TestCase {
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testJRockitAgent() {
- ClassPreProcessor preProcessor = new JRockitAgent();
- ClassPreProcessor expectedPreProcessor = JVMFactory.getJVM().getClassLibrary().getClassPreProcessor();
- assertEquals("JRocketAgent must be registered", expectedPreProcessor, preProcessor);
- }
-
- public void testPreProcess() {
- ClassPreProcessor preProcessor = new JRockitAgent();
- preProcessor.preProcess(null, "foo.Bar", new byte[] {});
- }
-
- public void testJrockitRecursionProtection() {
- URL jrockit = FileUtil.getFileURL(new File("../lib/jrockit/jrockit.jar"));
- URL[] urls = new URL[] {jrockit};
- URLClassLoader thisLoader = new URLClassLoader(urls, getClass().getClassLoader());
- try {
- ClassLoader loader = new JRockitClassLoader(thisLoader);
- Class.forName("java.lang.Object", false, loader);
- Class.forName("junit.framework.TestCase", false, loader);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail(ex.toString());
- }
- }
-
- private class JRockitClassLoader extends ClassLoader {
-
- public final static boolean debug = false;
-
- private List path = new LinkedList();
- // private com.bea.jvm.ClassPreProcessor agent;
- private Object agent;
- private Method preProcess;
-
- public JRockitClassLoader(URLClassLoader clone) throws Exception {
- /* Use extensions loader */
- super(clone.getParent());
-
- URL[] urls = clone.getURLs();
- for (URL value : urls) {
- Object pathElement;
- URL url = value;
- if (debug)
- System.out.println("JRockitClassLoader.JRockitClassLoader() url=" + url.getPath());
- File file = new File(encode(url.getFile()));
- if (debug)
- System.out.println("JRockitClassLoader.JRockitClassLoader() file" + file);
- if (file.isDirectory())
- pathElement = file;
- else if (file.exists() && file.getName().endsWith(".jar"))
- pathElement = new JarFile(file);
- else
- throw new RuntimeException(file.getAbsolutePath());
- path.add(pathElement);
- }
-
- Class agentClazz = Class.forName("org.aspectj.weaver.loadtime.JRockitAgent", false, this);
- Object obj = agentClazz.getDeclaredConstructor().newInstance();
- if (debug)
- System.out.println("JRockitClassLoader.JRockitClassLoader() obj=" + obj);
- this.agent = obj;
- byte[] bytes = new byte[] {};
- Class[] parameterTypes = new Class[] { java.lang.ClassLoader.class, java.lang.String.class, bytes.getClass() };
- preProcess = agentClazz.getMethod("preProcess", parameterTypes);
- }
-
- /* Get rid of escaped characters */
- private String encode(String s) {
- StringBuffer result = new StringBuffer();
- int i = s.indexOf("%");
- while (i != -1) {
- result.append(s.substring(0, i));
- String escaped = s.substring(i + 1, i + 3);
- s = s.substring(i + 3);
- Integer value = Integer.valueOf(escaped, 16);
- result.append(Character.valueOf((char) value.intValue()));
- i = s.indexOf("%");
- }
- result.append(s);
- return result.toString();
- }
-
- protected Class findClass(String name) throws ClassNotFoundException {
- if (debug)
- System.out.println("> JRockitClassLoader.findClass() name=" + name);
- Class clazz = null;
- try {
- clazz = super.findClass(name);
- } catch (ClassNotFoundException ex) {
- for (Iterator i = path.iterator(); clazz == null && i.hasNext();) {
- byte[] classBytes = null;
- try {
- Object pathElement = i.next();
- if (pathElement instanceof File) {
- File dir = (File) pathElement;
- String className = name.replace('.', '/') + ".class";
- File classFile = new File(dir, className);
- if (classFile.exists())
- classBytes = loadClassFromFile(name, classFile);
- } else {
- JarFile jar = (JarFile) pathElement;
- String className = name.replace('.', '/') + ".class";
- ZipEntry entry = jar.getEntry(className);
- if (entry != null)
- classBytes = loadBytesFromZipEntry(jar, entry);
- }
-
- if (classBytes != null) {
- clazz = defineClass(name, classBytes);
- }
- } catch (IOException ioException) {
- ex.printStackTrace();
- }
- }
- }
-
- if (debug)
- System.out.println("< JRockitClassLoader.findClass() name=" + name);
- return clazz;
- }
-
- private Class defineClass(String name, byte[] bytes) {
- if (debug)
- System.out.println("> JRockitClassLoader.defineClass() name=" + name);
- try {
- if (agent != null)
- preProcess.invoke(agent, new Object[] { this, name, bytes });
- } catch (IllegalAccessException iae) {
- iae.printStackTrace();
- throw new ClassFormatError(iae.getMessage());
- } catch (InvocationTargetException ite) {
- ite.printStackTrace();
- throw new ClassFormatError(ite.getTargetException().getMessage());
- }
- if (debug)
- System.out.println("< JRockitClassLoader.defineClass() name=" + name);
- return super.defineClass(name, bytes, 0, bytes.length);
- }
-
- private byte[] loadClassFromFile(String name, File file) throws IOException {
- if (debug)
- System.out.println("JRockitClassLoader.loadClassFromFile() file=" + file);
-
- byte[] bytes;
- bytes = new byte[(int) file.length()];
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(file);
- bytes = readBytes(fis, bytes);
- } finally {
- if (fis != null)
- fis.close();
- }
-
- return bytes;
- }
-
- private byte[] loadBytesFromZipEntry(JarFile jar, ZipEntry entry) throws IOException {
- if (debug)
- System.out.println("JRockitClassLoader.loadBytesFromZipEntry() entry=" + entry);
-
- byte[] bytes;
- bytes = new byte[(int) entry.getSize()];
- InputStream is = null;
- try {
- is = jar.getInputStream(entry);
- bytes = readBytes(is, bytes);
- } finally {
- if (is != null)
- is.close();
- }
-
- return bytes;
- }
-
- private byte[] readBytes(InputStream is, byte[] bytes) throws IOException {
- for (int offset = 0; offset < bytes.length;) {
- int read = is.read(bytes, offset, bytes.length - offset);
- offset += read;
- }
- return bytes;
- }
- }
-}
diff --git a/run-all-junit-tests/pom.xml b/run-all-junit-tests/pom.xml
index e98cd7f04..22a2245e5 100644
--- a/run-all-junit-tests/pom.xml
+++ b/run-all-junit-tests/pom.xml
@@ -240,13 +240,6 @@
<version>${lib.ant.version}</version>
</dependency>
<dependency>
- <groupId>jrockit</groupId>
- <artifactId>jrockit</artifactId>
- <version>1.0</version>
- <scope>system</scope>
- <systemPath>${project.basedir}/../lib/jrockit/jrockit.jar</systemPath>
- </dependency>
- <dependency>
<!-- Identical to lib/ant/lib/ant-launcher.jar, a former system-scoped dependency -->
<groupId>ant</groupId>
<artifactId>ant-launcher</artifactId>
diff --git a/tests/ltw/java/net/URLClassLoader.java b/tests/ltw/java/net/URLClassLoader.java
index 770c7f337..ffd9d57d1 100644
--- a/tests/ltw/java/net/URLClassLoader.java
+++ b/tests/ltw/java/net/URLClassLoader.java
@@ -17,9 +17,9 @@ import java.util.zip.ZipEntry;
import org.aspectj.weaver.loadtime.Aj;
public class URLClassLoader extends SecureClassLoader {
-
+
public final static boolean debug = false;
-
+
private List path = new LinkedList();
private Aj agent;
@@ -34,7 +34,7 @@ public class URLClassLoader extends SecureClassLoader {
public URLClassLoader(URL[] urls) throws IOException {
this(urls,null,null);
}
-
+
public URLClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) throws IOException {
super(parent);
if (debug) System.err.println("> URLClassLoader.URLClassLoader() parent=" + parent);
@@ -52,43 +52,10 @@ public class URLClassLoader extends SecureClassLoader {
}
agent = new Aj();
-
+
if (debug) System.err.println("< URLClassLoader.URLClassLoader() path=" + path);
}
-
-// public final static boolean debug = false;
-//
-// private List path = new LinkedList();
-//// private com.bea.jvm.ClassPreProcessor agent;
-// private Object agent;
-// private Method preProcess;
-
-// public JRockitClassLoader (URLClassLoader clone) throws Exception {
-// /* Use extensions loader */
-// super(clone.getParent());
-//
-// URL[] urls = clone.getURLs();
-// for (int i = 0; i < urls.length; i++) {
-// Object pathElement;
-// URL url = urls[i];
-// if (debug) System.err.println("JRockitClassLoader.JRockitClassLoader() url=" + url.getPath());
-// File file = new File(encode(url.getFile()));
-// if (debug) System.err.println("JRockitClassLoader.JRockitClassLoader() file" + file);
-// if (file.isDirectory()) pathElement = file;
-// else if (file.exists() && file.getName().endsWith(".jar")) pathElement = new JarFile(file);
-// else throw new RuntimeException(file.getAbsolutePath().toString());
-// path.add(pathElement);
-// }
-//
-// Class agentClazz = Class.forName("org.aspectj.weaver.loadtime.JRockitAgent",false,this);
-// Object obj = agentClazz.newInstance();
-// if (debug) System.err.println("JRockitClassLoader.JRockitClassLoader() obj=" + obj);
-// this.agent = obj;
-// byte[] bytes = new byte[] {};
-// Class[] parameterTypes = new Class[] { java.lang.ClassLoader.class, java.lang.String.class, bytes.getClass() };
-// preProcess = agentClazz.getMethod("preProcess",parameterTypes);
-// }
-
+
/* Get rid of escaped characters */
private String encode (String s) {
StringBuffer result = new StringBuffer();
@@ -104,7 +71,7 @@ public class URLClassLoader extends SecureClassLoader {
result.append(s);
return result.toString();
}
-
+
protected Class findClass(String name) throws ClassNotFoundException {
if (debug) System.err.println("> URLClassLoader.findClass() name=" + name);
Class clazz = null;
@@ -129,7 +96,7 @@ public class URLClassLoader extends SecureClassLoader {
ZipEntry entry = jar.getEntry(className);
if (entry != null) classBytes = loadBytesFromZipEntry(jar,entry);
}
-
+
if (classBytes != null) {
clazz = defineClass(name,classBytes);
}
@@ -139,7 +106,7 @@ public class URLClassLoader extends SecureClassLoader {
}
}
}
-
+
if (debug) System.err.println("< URLClassLoader.findClass() clazz=" + clazz);
if (clazz == null) throw new ClassNotFoundException(name);
return clazz;
@@ -160,12 +127,12 @@ public class URLClassLoader extends SecureClassLoader {
if (debug) System.err.println("< URLClassLoader.findResource() url=" + url);
return url;
}
-
-
+
+
protected Enumeration findResources (String name) throws IOException {
if (debug) System.err.println("> URLClassLoader.findResources() name=" + name);
Vector urls = new Vector();
-
+
for (Iterator i = path.iterator(); i.hasNext();) {
Object pathElement = i.next();
if (pathElement instanceof File) {
@@ -182,34 +149,34 @@ public class URLClassLoader extends SecureClassLoader {
final byte[] bytes = loadBytesFromZipEntry(jar,entry);
URLStreamHandler streamHandler = new URLStreamHandler() {
-
+
protected URLConnection openConnection(URL u) throws IOException {
URLConnection connection = new URLConnection(u) {
-
+
public void connect() throws IOException {
}
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(bytes);
}
-
+
};
return connection;
}
-
+
};
URL url = new URL("file",null,0,jar.getName(),streamHandler);
urls.add(url);
}
}
}
-
+
Enumeration enu = urls.elements();
-
+
if (debug) System.err.println("< URLClassLoader.findResources() enu=" + enu);
return enu;
}
-
+
private Class defineClass (String name, byte[] bytes) {
if (debug) System.err.println("> URLClassLoader.defineClass() name=" + name);
// try {
@@ -226,7 +193,7 @@ public class URLClassLoader extends SecureClassLoader {
if (debug) System.err.println("< URLClassLoader.defineClass() name=" + name);
return super.defineClass(name,bytes,0,bytes.length);
}
-
+
private byte[] loadClassFromFile (String name, File file) throws IOException {
if (debug) System.err.println("> URLClassLoader.loadClassFromFile() file=" + file);
@@ -240,11 +207,11 @@ public class URLClassLoader extends SecureClassLoader {
finally {
if (fis != null) fis.close();
}
-
+
if (debug) System.err.println("< URLClassLoader.loadClassFromFile() bytes=b[" + bytes.length + "]");
return bytes;
}
-
+
private byte[] loadBytesFromZipEntry (JarFile jar, ZipEntry entry) throws IOException {
if (debug) System.err.println("> URLClassLoader.loadBytesFromZipEntry() entry=" + entry);
@@ -258,11 +225,11 @@ public class URLClassLoader extends SecureClassLoader {
finally {
if (is != null) is.close();
}
-
+
if (debug) System.err.println("< URLClassLoader.loadBytesFromZipEntry() bytes=b[" + bytes.length + "]");
return bytes;
}
-
+
private byte[] readBytes (InputStream is, byte[] bytes) throws IOException {
for (int offset = 0; offset < bytes.length;) {
int read = is.read(bytes,offset,bytes.length - offset);