aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1133755 - in /aries/trunk/proxy/proxy-impl: ./ src/build/ src/build/resources/ src/build/resources/org/ src/build/resources/org/apache/ src/build/resources/org/apache/aries/ src/build/resources/org/apache/aries/proxy/ src/build/resources/o...
Date Thu, 09 Jun 2011 09:46:51 GMT
Author: timothyjward
Date: Thu Jun  9 09:46:51 2011
New Revision: 1133755

URL: http://svn.apache.org/viewvc?rev=1133755&view=rev
Log:
ARIES-669 : Mark WovenProxy interface "synthetic" - Patch from Richard Ellis altered to use
maven properties in absolute paths

Added:
    aries/trunk/proxy/proxy-impl/src/build/
    aries/trunk/proxy/proxy-impl/src/build/resources/
    aries/trunk/proxy/proxy-impl/src/build/resources/org/
    aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/
    aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/
    aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/
    aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/ 
 (with props)
    aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/Synthesizer.java
Modified:
    aries/trunk/proxy/proxy-impl/pom.xml
    aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java

Modified: aries/trunk/proxy/proxy-impl/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/pom.xml?rev=1133755&r1=1133754&r2=1133755&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/pom.xml (original)
+++ aries/trunk/proxy/proxy-impl/pom.xml Thu Jun  9 09:46:51 2011
@@ -142,4 +142,50 @@
         </dependency>
     </dependencies>
 
+    <build>
+     <plugins>
+       <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <!--  hack to make javac available to maven-antrun-plugin
+            because the maven-antrun-plugin runs with java.home set to the
+            jre subdirectory of a jdk, even if maven is using the jdk
+             -->
+            <dependencies>
+              <dependency>
+                <groupId>com.sun</groupId>
+                <artifactId>tools</artifactId>
+                <version>1.5.0</version>
+                <scope>system</scope>
+                <systemPath>${java.home}/../lib/tools.jar</systemPath>
+              </dependency>
+            </dependencies>
+         <executions>
+           <execution>
+             <phase>process-classes</phase>
+             <configuration>
+               <tasks>
+                 <!-- compile the Synthesizer which can add the synthetic modifier to
classes -->
+                 <javac srcdir="${basedir}/src/build/resources" includes="**/Synthesize*.java"
classpathref="maven.runtime.classpath"/>
+                 <!-- create a classpath that includes the compiled Synthesizer -->
+                 <path id="synthesizer.class.path">
+                   <dirset dir="${basedir}/src/build/resources"/>
+                   <path refid="maven.runtime.classpath"/>
+                 </path>
+                 <!-- run the Synthesizer on the WovenProxy class -->
+                 <java classname="org.apache.aries.proxy.synthesizer.Synthesizer"
+                       classpathref="synthesizer.class.path" fork="false">
+                       <arg value="${project.build.outputDirectory}/org/apache/aries/proxy/weaving/WovenProxy.class"/>
+                 </java>
+               </tasks>
+             </configuration>
+             <goals>
+               <goal>run</goal>
+             </goals>
+           </execution>
+         </executions>
+       </plugin>
+     </plugins>
+    </build>
+
 </project>

Propchange: aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jun  9 09:46:51 2011
@@ -0,0 +1 @@
+*.class

Added: aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/Synthesizer.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/Synthesizer.java?rev=1133755&view=auto
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/Synthesizer.java
(added)
+++ aries/trunk/proxy/proxy-impl/src/build/resources/org/apache/aries/proxy/synthesizer/Synthesizer.java
Thu Jun  9 09:46:51 2011
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.aries.proxy.synthesizer;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import org.objectweb.asm.ClassReader;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * The Synthesizer class can be run from a java command with arguments
+ * of paths to class files that should be modified to have the synthetic
+ * attribute added.
+ *
+ */
+public class Synthesizer
+{
+  /**
+   * This is the main method for running the Synthesizer
+   * 
+   * @param args - String[] of file paths to class files
+   * @throws Exception 
+   */
+  public static void main(String[] args) throws Exception
+  {
+    //add the synthetic modifier for each of the supplied args
+    for (String arg : args) {
+      FileInputStream classInStream = null;
+      ClassWriter writer = null;
+      try {
+        //read in the class
+        classInStream = new FileInputStream(arg);
+        ClassReader reader = new ClassReader(classInStream);
+        //make a ClassWriter constructed with the reader for speed
+        //since we are mostly just copying
+        //we just need to override the visit method so we can add
+        //the synthetic modifier, otherwise we use the methods in
+        //a standard writer
+        writer = new ClassWriter(reader, 0) {
+          @Override
+          public void visit(int version, int access, String name, String signature,
+              String superName, String[] interfaces)
+          {
+            super.visit(version, access | Opcodes.ACC_SYNTHETIC, name, signature, superName,
+                interfaces);
+          }
+        };
+        //call accept on the reader to start the visits
+        //using the writer we created as the visitor
+        reader.accept(writer, 0);
+      } finally {
+        //close the InputStream if it is hanging around
+        if (classInStream != null) classInStream.close();
+      }
+      FileOutputStream classOutStream = null;
+      try {
+        //write out the new bytes of the class file
+        classOutStream = new FileOutputStream(arg);
+        if (writer != null) classOutStream.write(writer.toByteArray());
+      } finally {
+        //close the OutputStream if it is still around
+        if (classOutStream != null) classOutStream.close();
+      }
+    }
+  }
+}

Modified: aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java?rev=1133755&r1=1133754&r2=1133755&view=diff
==============================================================================
--- aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
(original)
+++ aries/trunk/proxy/proxy-impl/src/test/java/org/apache/aries/blueprint/proxy/WovenProxyGeneratorTest.java
Thu Jun  9 09:46:51 2011
@@ -379,5 +379,14 @@ public class WovenProxyGeneratorTest ext
   protected Object getP3() {
     return getProxyInstance(getProxyClass(TEST_CLASS));
   }
+  
+  /**
+   * This tests that the Synthesizer ran correctly and the packaged
+   * WovenProxy class has been modified with the synthetic modifier
+   */
+  @Test
+  public void testWovenProxyIsSynthetic(){
+    assertTrue(WovenProxy.class.isSynthetic());
+  }
 }
 



Mime
View raw message