tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r1196360 - in /tapestry/tapestry5/trunk: tapestry-core/ tapestry-ioc/ tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/
Date Tue, 01 Nov 2011 23:09:52 GMT
Author: hlship
Date: Tue Nov  1 23:09:51 2011
New Revision: 1196360

URL: http://svn.apache.org/viewvc?rev=1196360&view=rev
Log:
TAP5-1739: Convert test case for synthetic method in module class to use ASM, not Javassist

Modified:
    tapestry/tapestry5/trunk/tapestry-core/build.gradle
    tapestry/tapestry5/trunk/tapestry-ioc/build.gradle
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
    tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/SyntheticMethodModule.java

Modified: tapestry/tapestry5/trunk/tapestry-core/build.gradle
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/build.gradle?rev=1196360&r1=1196359&r2=1196360&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/build.gradle (original)
+++ tapestry/tapestry5/trunk/tapestry-core/build.gradle Tue Nov  1 23:09:51 2011
@@ -27,6 +27,8 @@ dependencies {
     antlr3 "org.antlr:antlr:3.3"
 
     testRuntime "org.hsqldb:hsqldb:1.8.0.10"
+
+    testCompile "javassist:javassist:3.12.1.GA"
 }
 
 // This may spin out as a plugin once we've got the details down pat

Modified: tapestry/tapestry5/trunk/tapestry-ioc/build.gradle
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/build.gradle?rev=1196360&r1=1196359&r2=1196360&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/build.gradle (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/build.gradle Tue Nov  1 23:09:51 2011
@@ -7,8 +7,6 @@ dependencies {
 
   provided project(':tapestry-test')
 
-  compile "javassist:javassist:3.12.1.GA"
-
   compile "javax.inject:javax.inject:1"
 
   compile "org.slf4j:slf4j-api:1.6.1"

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java?rev=1196360&r1=1196359&r2=1196360&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/DefaultModuleDefImplTest.java
Tue Nov  1 23:09:51 2011
@@ -14,8 +14,11 @@
 
 package org.apache.tapestry5.ioc.internal;
 
-import javassist.bytecode.AccessFlag;
+import org.apache.tapestry5.internal.plastic.ClassLoaderDelegate;
+import org.apache.tapestry5.internal.plastic.PlasticClassLoader;
+import org.apache.tapestry5.internal.plastic.PlasticInternalUtils;
 import org.apache.tapestry5.internal.plastic.asm.ClassWriter;
+import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
 import org.apache.tapestry5.ioc.*;
 import org.apache.tapestry5.ioc.def.ContributionDef;
 import org.apache.tapestry5.ioc.def.DecoratorDef;
@@ -32,10 +35,9 @@ import org.testng.annotations.BeforeClas
 import org.testng.annotations.Test;
 
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.List;
 import java.util.Set;
 
+import static org.apache.tapestry5.internal.plastic.asm.Opcodes.*;
 import static org.easymock.EasyMock.contains;
 
 public class DefaultModuleDefImplTest extends IOCTestCase
@@ -649,29 +651,42 @@ public class DefaultModuleDefImplTest ex
 
     private Class createSyntheticMethodModuleClass() throws NoSuchMethodException
     {
-                /*
-        ClassFab fab = classFactory.newClass("EnhancedSyntheticMethodModule", SyntheticMethodModule.class);
 
-        int modifiers = Modifier.PUBLIC | AccessFlag.SYNTHETIC;
+        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
 
-        // choose arbitrary signature
+        cw.visit(V1_5, ACC_PUBLIC, "EnhancedSyntheticMethodModule", null,
+                PlasticInternalUtils.toInternalName(SyntheticMethodModule.class.getName()),
null);
 
-        MethodSignature signature = new MethodSignature(List.class.getMethod("size"));
+        MethodVisitor mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "synth",
"()V", null, null);
+        mv.visitCode();
+        mv.visitInsn(RETURN);
+        mv.visitEnd();
 
-        fab.addMethod(modifiers, signature, "return 0;");
+        cw.visitEnd();
 
-        Class moduleClass = fab.createClass();
+        byte[] bytecode = cw.toByteArray();
 
-        // make sure we really managed to create a synthetic method
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
 
-        assertTrue(moduleClass.getMethod("size").isSynthetic());
+        PlasticClassLoader plasticLoader = new PlasticClassLoader(loader, new NoopDelegate());
 
-        return moduleClass;       */
-
-        return null;
+        return plasticLoader.defineClassWithBytecode("EnhancedSyntheticMethodModule", bytecode);
     }
 
     // TODO: We're short on tests that ensure that marker annotation are additive (i.e.,
module
     // marker annotation are
     // merged into the set specific to the service).
+
+    private static class NoopDelegate implements ClassLoaderDelegate
+    {
+        public boolean shouldInterceptClassLoading(String className)
+        {
+            return false;
+        }
+
+        public Class<?> loadAndTransformClass(String className) throws ClassNotFoundException
+        {
+            return null;
+        }
+    }
 }

Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/SyntheticMethodModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/SyntheticMethodModule.java?rev=1196360&r1=1196359&r2=1196360&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/SyntheticMethodModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry5/ioc/internal/SyntheticMethodModule.java
Tue Nov  1 23:09:51 2011
@@ -1,4 +1,4 @@
-// Copyright 2009, 2010 The Apache Software Foundation
+// Copyright 2009, 2010, 2011 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -18,13 +18,13 @@ package org.apache.tapestry5.ioc.interna
 
 public class SyntheticMethodModule
 {
-    public Object build()
+    public static Object build()
     {
         return new Object();
     }
 
     /** Methods with a leading '$' are ignored as well, mostly for Scala support. */
-    public Object $ignored()
+    public static Object $ignored()
     {
         return null;
     }



Mime
View raw message