You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openjpa.apache.org by pc...@apache.org on 2007/09/14 01:19:14 UTC

svn commit: r575492 - in /openjpa/branches/1.0.x: openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java

Author: pcl
Date: Thu Sep 13 16:19:13 2007
New Revision: 575492

URL: http://svn.apache.org/viewvc?rev=575492&view=rev
Log:
OPENJPA-335

Added:
    openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java
Modified:
    openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java

Modified: openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?rev=575492&r1=575491&r2=575492&view=diff
==============================================================================
--- openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original)
+++ openjpa/branches/1.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Thu Sep 13 16:19:13 2007
@@ -696,8 +696,8 @@
 
         BCField field = null, cur;
         Instruction templateIns, prevIns, earlierIns;
-        int backupCount = 3;
         while (code.searchForward(template)) {
+            int backupCount = 3;
             templateIns = code.previous();
             if (!code.hasPrevious())
                 return null;

Added: openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java?rev=575492&view=auto
==============================================================================
--- openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java (added)
+++ openjpa/branches/1.0.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java Thu Sep 13 16:19:13 2007
@@ -0,0 +1,46 @@
+/*
+ * 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.openjpa.enhance;
+
+import junit.framework.TestCase;
+import serp.bytecode.BCClass;
+import serp.bytecode.BCField;
+import serp.bytecode.BCMethod;
+import serp.bytecode.Project;
+
+public class TestPCEnhancerFindField
+    extends TestCase {
+
+    private String field;
+
+    public String myMethod() {
+        if (Math.abs(1) == 1)
+            return field;
+        else
+            return field;
+    }
+
+    public void testPCEnhancerFindField() {
+        Project proj = new Project();
+        BCClass bc = proj.loadClass(getClass());
+        BCMethod meth = bc.getMethods("myMethod")[0];
+        BCField field = PCEnhancer.getReturnedField(meth);
+        assertEquals("field", field.getName());
+    }
+}