From 809cb370030c72970ed499c3003aa5400b3a276e Mon Sep 17 00:00:00 2001 From: Patrick Linskey Date: Thu, 13 Sep 2007 23:24:12 +0000 Subject: [PATCH] OPENJPA-335. 'svn merge -c 575492 ../branches/1.0.x' git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@575495 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/openjpa/enhance/PCEnhancer.java | 2 +- .../enhance/TestPCEnhancerFindField.java | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java index be891577c..1a7b5a130 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java @@ -696,8 +696,8 @@ public class PCEnhancer { 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; diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java new file mode 100644 index 000000000..d3b8e3e61 --- /dev/null +++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/enhance/TestPCEnhancerFindField.java @@ -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()); + } +}