commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1532231 - in /commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow: ant/ bytecode/ bytecode/transformation/asm/ stores/ utils/
Date Tue, 15 Oct 2013 07:39:14 GMT
Author: ebourg
Date: Tue Oct 15 07:39:14 2013
New Revision: 1532231

URL: http://svn.apache.org/r1532231
Log:
Java 5 syntax

Modified:
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/Stack.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/stores/TransformingResourceStore.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/CompositeTransformer.java
    commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/ant/AntRewriteTask.java
Tue Oct 15 07:39:14 2013
@@ -112,9 +112,7 @@ public class AntRewriteTask extends Matc
         }
 
         try {
-            for (int i = 0; i < fileNames.length; i++) {
-                final String fileName = fileNames[i];
-                
+            for (final String fileName : fileNames) {
                 final File source = new File(srcDir, fileName);
                 final File destination = new File(dstDir, fileName);
                 

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/Stack.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/Stack.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/Stack.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/Stack.java
Tue Oct 15 07:39:14 2013
@@ -288,7 +288,7 @@ public class Stack implements Serializab
 
     private String getStats() {
         if (log.isDebugEnabled()) {
-            final StringBuffer sb = new StringBuffer();
+            final StringBuilder sb = new StringBuilder();
             sb.append("i[").append(iTop).append("],");
             sb.append("l[").append(lTop).append("],");
             sb.append("d[").append(dTop).append("],");
@@ -302,7 +302,7 @@ public class Stack implements Serializab
     }
 
     private String getContent() {
-        final StringBuffer sb = new StringBuffer();
+        final StringBuilder sb = new StringBuilder();
         sb.append("i[").append(iTop).append("]\n");
         sb.append("l[").append(lTop).append("]\n");
         sb.append("d[").append(dTop).append("]\n");

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/bytecode/transformation/asm/ContinuationMethodAdapter.java
Tue Oct 15 07:39:14 2013
@@ -23,7 +23,6 @@ import org.objectweb.asm.Label;
 import org.objectweb.asm.MethodVisitor;
 import org.objectweb.asm.Opcodes;
 import org.objectweb.asm.Type;
-import org.objectweb.asm.tree.AbstractInsnNode;
 import org.objectweb.asm.tree.MethodInsnNode;
 import org.objectweb.asm.tree.analysis.Analyzer;
 import org.objectweb.asm.tree.analysis.BasicValue;
@@ -90,10 +89,10 @@ public final class ContinuationMethodAda
 
         // switch cases
         for (int i = 0; i < fsize; i++) {
-            Label frameLabel = (Label) labels.get(i);
+            Label frameLabel = labels.get(i);
             mv.visitLabel(restoreLabels[i]);
 
-            MethodInsnNode mnode = (MethodInsnNode) nodes.get(i);
+            MethodInsnNode mnode = nodes.get(i);
             Frame frame = analyzer.getFrames()[canalyzer.getIndex(mnode)];
 
             // for each local variable store the value in locals popping it from the stack!
@@ -132,9 +131,9 @@ public final class ContinuationMethodAda
             if (frame instanceof MonitoringFrame) {
                 int[] monitoredLocals = ((MonitoringFrame) frame).getMonitored();
                 // System.out.println(System.identityHashCode(frame)+" AMonitored locals
"+monitoredLocals.length);
-                for (int j = 0; j < monitoredLocals.length; j++) {
+                for (int monitoredLocal : monitoredLocals) {
                     // System.out.println(System.identityHashCode(frame)+" AMonitored local
"+monitoredLocals[j]);
-                    mv.visitVarInsn(ALOAD, monitoredLocals[j]);
+                    mv.visitVarInsn(ALOAD, monitoredLocal);
                     mv.visitInsn(MONITORENTER);
                 }
             }
@@ -177,9 +176,8 @@ public final class ContinuationMethodAda
             }
 
             // Create null types for the parameters of the method invocation
-            Type[] paramTypes = Type.getArgumentTypes(mnode.desc);
-            for (int j = 0; j < paramTypes.length; j++) {
-                pushDefault(paramTypes[j]);
+            for (Type paramType : Type.getArgumentTypes(mnode.desc)) {
+                pushDefault(paramType);
             }
 
             // continue to the next method
@@ -193,7 +191,7 @@ public final class ContinuationMethodAda
 
     public void visitLabel(Label label) {
         if (currentIndex < labels.size() && label == labels.get(currentIndex))
{
-            int i = canalyzer.getIndex((AbstractInsnNode)nodes.get(currentIndex));
+            int i = canalyzer.getIndex(nodes.get(currentIndex));
             currentFrame = analyzer.getFrames()[i];
         }
         mv.visitLabel(label);
@@ -288,9 +286,9 @@ public final class ContinuationMethodAda
             if (currentFrame instanceof MonitoringFrame) {
                 int[] monitoredLocals = ((MonitoringFrame) currentFrame).getMonitored();
                 // System.out.println(System.identityHashCode(currentFrame)+" Monitored locals
"+monitoredLocals.length);
-                for (int j = 0; j < monitoredLocals.length; j++) {
+                for (int monitoredLocal : monitoredLocals) {
                     // System.out.println(System.identityHashCode(currentFrame)+" Monitored
local "+monitoredLocals[j]);
-                    mv.visitVarInsn(ALOAD, monitoredLocals[j]);
+                    mv.visitVarInsn(ALOAD, monitoredLocal);
                     mv.visitInsn(MONITOREXIT);
                 }
             }

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/stores/TransformingResourceStore.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/stores/TransformingResourceStore.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/stores/TransformingResourceStore.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/stores/TransformingResourceStore.java
Tue Oct 15 07:39:14 2013
@@ -41,9 +41,9 @@ public class TransformingResourceStore i
         // FIXME: make the matching configurable
         //if (resourceName.endsWith(".class")) {
             byte[] in = resourceData;
-            
-            for(int i=0; i<transformers.length; i++) {
-                out = transformers[i].transform(in);
+
+            for (ResourceTransformer transformer : transformers) {
+                out = transformer.transform(in);
                 in = out;
             }
         //}

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/CompositeTransformer.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/CompositeTransformer.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/CompositeTransformer.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/CompositeTransformer.java
Tue Oct 15 07:39:14 2013
@@ -30,8 +30,8 @@ public class CompositeTransformer implem
     }
 
     public byte[] transform(byte[] image) {
-        for (int i = 0; i < transformers.length; i++) {
-            image = transformers[i].transform(image);
+        for (ResourceTransformer transformer : transformers) {
+            image = transformer.transform(image);
         }
         return image;
     }

Modified: commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java?rev=1532231&r1=1532230&r2=1532231&view=diff
==============================================================================
--- commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java
(original)
+++ commons/sandbox/javaflow/trunk/src/main/java/org/apache/commons/javaflow/utils/ReflectionUtils.java
Tue Oct 15 07:39:14 2013
@@ -82,13 +82,12 @@ public final class ReflectionUtils {
 
         Class<?> current = pClazz;
         do {
-            final Field[] fields = current.getDeclaredFields();
-            for (int i = 0; i < fields.length; i++) {
-                final String fname = fields[i].getName();
+            for (Field field : current.getDeclaredFields()) {
+                final String fname = field.getName();
                 if (pMatcher.matches(fname)) {
-                    pIndexer.put(result, fname, fields[i]);
+                    pIndexer.put(result, fname, field);
 
-                    log.debug("discovered field " + fname + " -> " + fields[i]);
+                    log.debug("discovered field " + fname + " -> " + field);
                 }
             }
             current = current.getSuperclass();
@@ -125,13 +124,12 @@ public final class ReflectionUtils {
 
         Class<?> current = pClazz;
         do {
-            final Method[] methods = current.getDeclaredMethods();
-            for (int i = 0; i < methods.length; i++) {
-                final String mname = methods[i].getName();
+            for (Method method : current.getDeclaredMethods()) {
+                final String mname = method.getName();
                 if (pMatcher.matches(mname)) {
-                    pIndexer.put(result, mname, methods[i]);
+                    pIndexer.put(result, mname, method);
 
-                    log.debug("discovered method " + mname + " -> " + methods[i]);
+                    log.debug("discovered method " + mname + " -> " + method);
                 }
             }
             current = current.getSuperclass();



Mime
View raw message