Allow use of reflection to access private id fields of pre-1.5 classes.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@495650 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2007-01-12 17:25:25 +00:00
parent 6eae1a37ae
commit 3dd1c43165
3 changed files with 8 additions and 22 deletions

View File

@ -39,7 +39,6 @@ import org.apache.openjpa.lib.util.Localizer.Message;
import org.apache.openjpa.meta.JavaTypes;
import org.apache.openjpa.meta.MetaDataContext;
import org.apache.openjpa.util.MetaDataException;
import serp.util.Strings;
/**

View File

@ -1550,7 +1550,7 @@ public class PCEnhancer {
if (reflect) {
code.constant().setValue(oidType);
code.constant().setValue(name);
setClassConstant(code, type);
setClassConstant(_pc, code, type);
code.constant().setValue(true);
code.invokestatic().setMethod(Reflection.class,
"findSetter", Method.class, new Class[] { Class.class,
@ -1601,25 +1601,13 @@ public class PCEnhancer {
}
/**
* Works around a bug in serp when primitive type constants.
* Works around a bug in serp with primitive type constants, and chooses
* Java 5 construct when available (serp will eventually do all this
* automatically).
*/
private static void setClassConstant(Code code, Class type) {
if (type == boolean.class)
code.getstatic().setField(Boolean.class, "TYPE", Class.class);
else if (type == byte.class)
code.getstatic().setField(Byte.class, "TYPE", Class.class);
else if (type == char.class)
code.getstatic().setField(Character.class, "TYPE", Class.class);
else if (type == double.class)
code.getstatic().setField(Double.class, "TYPE", Class.class);
else if (type == float.class)
code.getstatic().setField(Float.class, "TYPE", Class.class);
else if (type == int.class)
code.getstatic().setField(Integer.class, "TYPE", Class.class);
else if (type == long.class)
code.getstatic().setField(Long.class, "TYPE", Class.class);
else if (type == short.class)
code.getstatic().setField(Short.class, "TYPE", Class.class);
private static void setClassConstant(BCClass bc, Code code, Class type) {
if (type.isPrimitive() || bc.getMajorVersion() < 49) // 49 = Java 5
code.classconstant().setClass(type);
else
code.constant().setValue(type);
}

View File

@ -643,8 +643,7 @@ public abstract class AbstractCFMetaDataFactory
} else {
if (log.isTraceEnabled())
log.trace(_loc.get("scanning-url", url));
clss = cparser.parseTypeNames(new URLMetaDataIterator
(url));
clss = cparser.parseTypeNames(new URLMetaDataIterator(url));
names.addAll(Arrays.asList(clss));
mapPersistentTypeNames(url, clss);
}