commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r413604 - in /jakarta/commons/sandbox/javaflow/trunk/src: java/org/apache/commons/javaflow/bytecode/ test/org/apache/commons/javaflow/bytecode/transformation/ test/org/apache/commons/javaflow/bytecode/transformation/rewrite/ test/org/apache...
Date Mon, 12 Jun 2006 08:05:05 GMT
Author: tcurdt
Date: Mon Jun 12 01:05:05 2006
New Revision: 413604

URL: http://svn.apache.org/viewvc?rev=413604&view=rev
Log:
minor testcase cleanups

Modified:
    jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/BytecodeClassLoader.java
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/ClassTransformerClassLoader.java
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/CounterFlow.java
    jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java

Modified: jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/BytecodeClassLoader.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/BytecodeClassLoader.java?rev=413604&r1=413603&r2=413604&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/BytecodeClassLoader.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/java/org/apache/commons/javaflow/bytecode/BytecodeClassLoader.java
Mon Jun 12 01:05:05 2006
@@ -30,9 +30,9 @@
         
         final String name = nameClassAdapter.getName().replace('/', '.');
         
-        System.out.println("loading class " + name);
+//        System.out.println("loading class " + name);
         
-        final Class clazz = defineClass(null, bytecode, 0, bytecode.length);
+        final Class clazz = defineClass(name, bytecode, 0, bytecode.length);
         
         return clazz;
     }

Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/ClassTransformerClassLoader.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/ClassTransformerClassLoader.java?rev=413604&r1=413603&r2=413604&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/ClassTransformerClassLoader.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/ClassTransformerClassLoader.java
Mon Jun 12 01:05:05 2006
@@ -15,7 +15,6 @@
 
     private final ResourceTransformer transformer;
     private final String prefix;
-//    private final ClassLoader classloader;
 
     public ClassTransformerClassLoader(final ResourceTransformer pTransformer) {
     	this("org.apache.commons.javaflow.bytecode.transformation.", pTransformer);
@@ -24,7 +23,6 @@
     public ClassTransformerClassLoader(final String pPrefix, final ResourceTransformer pTransformer)
{
         prefix = pPrefix;
         transformer = pTransformer;
-//        classloader = getClass().getClassLoader();
     }
 
     protected byte[] transform( final InputStream pClassStream ) throws IOException {
@@ -81,34 +79,29 @@
     public Class loadClass( final String name ) throws ClassNotFoundException {
         if (name.startsWith(prefix)) {
 
-//        	Class clazz = super.findClass(name);
-//        	if (clazz != null) {
-//        		return clazz;
-//        	}
-        	
-//            System.err.println("Loading: " + name);
             try {
                 final InputStream is = getClass().getResourceAsStream(
                         "/" + name.replace('.', '/') + ".class");
+
                 byte[] bytecode;
                 if (name.indexOf(".rewrite.") >= 0) {
 //                    System.err.println("Instrumenting: " + name);
-                    // bytecode = DefaultConstructorDump.dump();
-                    bytecode = transform(is);
-                    /*
+
+                	bytecode = transform(is);
+
+                	/*
                      * FileOutputStream os = new FileOutputStream(name+".class");
                      * os.write(bytecode); os.flush(); os.close();
                      */
-                    // CheckClassAdapter.verify(new ClassReader(bytecode), true);
+
+                	// CheckClassAdapter.verify(new ClassReader(bytecode), true);
                 } else {
                     ClassReader cr = new ClassReader(is);
                     bytecode = cr.b;
                 }
+                
                 return super.defineClass(name, bytecode, 0, bytecode.length);
-                // } catch( Error ex) {
-                // new ClassReader(bytecode).accept(new TraceClassVisitor(new
-                // PrintWriter(System.err)), false);
-                // throw ex;
+
             } catch (Throwable ex) {
                 System.err.println("Load error: " + ex.toString());
                 ex.printStackTrace();
@@ -117,6 +110,5 @@
         }
 //        System.err.println("Other classloader loading: " + name);
         return super.loadClass(name);
-        //return classloader.loadClass(name);
     }
 }

Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/CounterFlow.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/CounterFlow.java?rev=413604&r1=413603&r2=413604&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/CounterFlow.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/rewrite/CounterFlow.java
Mon Jun 12 01:05:05 2006
@@ -16,7 +16,7 @@
 
   public void run() {
     for( int i = 0; i < up; i++) {
-      System.err.println(i);
+//      System.err.println(i);
       Continuation.suspend();
     }
   }

Modified: jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java?rev=413604&r1=413603&r2=413604&view=diff
==============================================================================
--- jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
(original)
+++ jakarta/commons/sandbox/javaflow/trunk/src/test/org/apache/commons/javaflow/bytecode/transformation/tests/AbstractSerializationTestCase.java
Mon Jun 12 01:05:05 2006
@@ -39,23 +39,6 @@
         
     }
 
-//    private void saveXStream(final Object c1, final File output) throws IOException {
-//        final XStream xstream = new XStream(new DomDriver());
-//        final String xml = xstream.toXML(c1);
-//        final FileOutputStream fos = new FileOutputStream(output);
-//        fos.write(xml.getBytes());
-//        fos.close();
-//    }
-//
-//    private Object loadXStream(final File input) throws IOException {
-//        final String xml = FileUtils.readFully(new FileReader(input));
-//        final XStream xstream = new XStream(new DomDriver());
-//        xstream.setClassLoader(getClass().getClassLoader());
-//        final Object o = xstream.fromXML(xml);
-//    	return o;
-//    }
-    
-    
     public class ObjectInputStreamExt extends ObjectInputStream {
 
         private ClassLoader classloader;
@@ -68,13 +51,11 @@
         protected Class resolveClass(ObjectStreamClass classDesc) throws IOException, ClassNotFoundException
{
 
         	return Class.forName(classDesc.getName(), true, classloader);
-        	//return classloader.loadClass(classDesc.getName());
         }
 
         protected Class resolveProxyClass(String[] interfaces) throws IOException, ClassNotFoundException
{
             Class[] cinterfaces = new Class[interfaces.length];
             for (int i = 0; i < interfaces.length; i++) {
-//                cinterfaces[i] = classloader.loadClass(interfaces[i]);
             	cinterfaces[i] = Class.forName(interfaces[i], true, classloader);
             }
             
@@ -104,6 +85,8 @@
         testSuspend();
         assertTrue("suspend must succeed to create the output first", output != null);
 
+        assertEquals(output.length(), 586);
+        
         final Object o = loadJDK(output);
         
         assertTrue(o instanceof Continuation);
@@ -112,10 +95,6 @@
         final Runnable r1 = (Runnable) PrivateAccessor.getField(sr1, "runnable");
         assertEquals(SimpleSerializable.class.getName(), r1.getClass().getName());
         
-        System.out.println(AbstractSerializationTestCase.class.getName() + "@" + AbstractSerializationTestCase.class.getClassLoader());
-        System.out.println(SimpleSerializable.class.getName() + "@" + SimpleSerializable.class.getClassLoader());
-        System.out.println(r1.getClass().getName() + "@" + r1.getClass().getClassLoader());
-        
         final SimpleSerializable ss1 = (SimpleSerializable)r1;
         assertTrue(ss1.g == 0);
         assertTrue(ss1.l == 0);
@@ -135,10 +114,12 @@
         Continuation c1 = Continuation.startWith(r1);
         assertTrue(c1 != null);
         assertTrue(!c1.isSerializable());
+
         final Runnable r2 = new SimpleSerializable();
         Continuation c2 = Continuation.startWith(r2);
         assertTrue(c2 != null);
         assertTrue(c2.isSerializable());
+
         final Runnable r3 = new SimpleSerializable();
         Continuation c3 = Continuation.startWith(new Invoker(r3));
         assertTrue(c3 != null);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message