[jboss-cvs] javassist SVN: r633 - in trunk: src/main/javassist/compiler and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jun 6 10:34:03 EDT 2012


Author: chiba
Date: 2012-06-06 10:34:02 -0400 (Wed, 06 Jun 2012)
New Revision: 633

Added:
   trunk/src/test/test4/JIRA166.java
Modified:
   trunk/Readme.html
   trunk/src/main/javassist/compiler/TypeChecker.java
   trunk/src/test/javassist/JvstTest4.java
Log:
fixed JASSIST-166

Modified: trunk/Readme.html
===================================================================
--- trunk/Readme.html	2012-06-05 16:03:48 UTC (rev 632)
+++ trunk/Readme.html	2012-06-06 14:34:02 UTC (rev 633)
@@ -283,7 +283,8 @@
 
 <p>-version 3.17
 <ul>
-	<li>JIRA JASSIST-168.
+	<li>OSGi bundle info is now included in the jar file.
+	<li>JIRA JASSIST-166, 168 have been fixed.
 </ul>
 
 <p>-version 3.16.1 on March 6, 2012

Modified: trunk/src/main/javassist/compiler/TypeChecker.java
===================================================================
--- trunk/src/main/javassist/compiler/TypeChecker.java	2012-06-05 16:03:48 UTC (rev 632)
+++ trunk/src/main/javassist/compiler/TypeChecker.java	2012-06-06 14:34:02 UTC (rev 633)
@@ -899,6 +899,9 @@
 
     public void atArrayLength(Expr expr) throws CompileError {
         expr.oprand1().accept(this);
+        if (arrayDim == 0)
+            throw new NoFieldException("length", expr);
+
         exprType = INT;
         arrayDim = 0;
     }

Modified: trunk/src/test/javassist/JvstTest4.java
===================================================================
--- trunk/src/test/javassist/JvstTest4.java	2012-06-05 16:03:48 UTC (rev 632)
+++ trunk/src/test/javassist/JvstTest4.java	2012-06-06 14:34:02 UTC (rev 633)
@@ -711,4 +711,17 @@
         assertTrue(javassist.runtime.Desc.getClazz("[Ljava.lang.String;") != null);
         javassist.runtime.Desc.useContextClassLoader = old;
     }
+
+    public void testJIRA166() throws Exception {
+        CtClass cc = sloader.get("test4.JIRA166");
+        cc.instrument(new ExprEditor() {
+            public void edit(FieldAccess fa) throws CannotCompileException {
+                if (fa.isReader() && fa.getFieldName().equals("length"))
+                    fa.replace("length = self().length + \"!\"; $_ = ($r) this.length.substring(1);");
+            }
+        });
+        cc.writeFile();
+        Object obj = make(cc.getName());
+        assertEquals(1, invoke(obj, "run"));
+    }
 }

Added: trunk/src/test/test4/JIRA166.java
===================================================================
--- trunk/src/test/test4/JIRA166.java	                        (rev 0)
+++ trunk/src/test/test4/JIRA166.java	2012-06-06 14:34:02 UTC (rev 633)
@@ -0,0 +1,12 @@
+package test4;
+
+public class JIRA166 {
+    String length = "jira166";
+    JIRA166 self() { return this; }
+    void print() { System.out.println(length); }
+    public int run() {
+        print();
+        System.out.println(length);
+        return 1;
+    }
+}


Property changes on: trunk/src/test/test4/JIRA166.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



More information about the jboss-cvs-commits mailing list