]> source.dussan.org Git - aspectj.git/commitdiff
Remove JRockit LTW support, particularly JRockitAgent
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 10 Apr 2021 05:32:04 +0000 (12:32 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Sat, 10 Apr 2021 05:33:08 +0000 (12:33 +0700)
In two places, the documentation now contains this text:

"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."

The decision to drop JRockit support was made during a discussion
between Alexander Kriegisch and Andy Clement:

Andy Clement wrote on 26 Mar 2021:

> Yes I think so.
>
>
> Alexander Kriegisch wrote on 26 Mar 2021:
>
>> https://en.wikipedia.org/wiki/JRockit
>>
>> Can we get rid of that? AspectJ requires Java 8, JRockit never
>> supported more than Java 6.

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
15 files changed:
build/src/main/java/org/aspectj/internal/tools/build/Builder.properties
docs/devGuideDB/ltw.xml
lib/jrockit/LICENSE.TXT [deleted file]
lib/jrockit/jrockit-src.zip [deleted file]
lib/jrockit/jrockit.jar [deleted file]
lib/jrockit/managementapi-jrockit81.jar [deleted file]
libx/pom.xml
loadtime/pom.xml
loadtime/src/main/java/org/aspectj/weaver/loadtime/JRockitAgent.java [deleted file]
loadtime/src/test/java/org/aspectj/bea/jvm/ClassLibraryImpl.java [deleted file]
loadtime/src/test/java/org/aspectj/bea/jvm/JVMImpl.java [deleted file]
loadtime/src/test/java/org/aspectj/loadtime/LoadtimeModuleTests.java
loadtime/src/test/java/org/aspectj/weaver/loadtime/JRockitAgentTest.java [deleted file]
run-all-junit-tests/pom.xml
tests/ltw/java/net/URLClassLoader.java

index 3838514f40405397c58485f29ed40e9d33b5ec4d..64998977aa39ef119592075373480e53d91e5892 100644 (file)
@@ -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
index 3d8723662a2ffb5cff4a0c0c8b1d52dec96f4179..bc5aac769f501037eb840ef6bc91be5368347d79 100644 (file)
@@ -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
                 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
                 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
                 <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>
                     <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>
                 </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
               <!-- 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
                 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.
                 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
                 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>
                     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
                     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>
             ]]></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
                             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.
                             <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>
                                 <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>
                             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>
     <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>
             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">
         </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 (file)
index 6bbc97c..0000000
+++ /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 (file)
index dce223d..0000000
Binary files a/lib/jrockit/jrockit-src.zip and /dev/null differ
diff --git a/lib/jrockit/jrockit.jar b/lib/jrockit/jrockit.jar
deleted file mode 100644 (file)
index 0395fce..0000000
Binary files a/lib/jrockit/jrockit.jar and /dev/null differ
diff --git a/lib/jrockit/managementapi-jrockit81.jar b/lib/jrockit/managementapi-jrockit81.jar
deleted file mode 100644 (file)
index f951295..0000000
Binary files a/lib/jrockit/managementapi-jrockit81.jar and /dev/null differ
index 8670f1a08482a5e73c0528d219a716df4b30d07b..4df26b50a882d2ce6c39cc78e535a0605a0c68dc 100644 (file)
                   <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>
index d7333cd7257cfd60d841053904a8a5587a44e8a2..7c03455e536d2c93d3d000ffc624fcc15f24bfae 100644 (file)
                        <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 (file)
index 56ad0e9..0000000
+++ /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 (file)
index 8b4c584..0000000
+++ /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 (file)
index caae32e..0000000
+++ /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;
-       }
-
-}
index 9d365ffab9943c31b3532919a844e6be094d4644..352156f8258ee3488628fdb529fb546f56833fa3 100644 (file)
@@ -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 (file)
index 7f9d235..0000000
+++ /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;
-               }
-       }
-}
index e98cd7f04caae9e658407cee16786f111fc9d7c3..22a2245e54fae5ee2a70e49aa9c3526d95427a3d 100644 (file)
                        <artifactId>ant</artifactId>
                        <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>
index 770c7f337df6cbc0e1da018512965924a618b6ee..ffd9d57d13a138a1b9b2b19725b1c6057cc71a98 100644 (file)
@@ -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);