mirror of https://github.com/apache/openjpa.git
OPENJPA-2911 remove Serp from PCSubclassValidator
This commit is contained in:
parent
3ea2412003
commit
d13b85b139
|
@ -619,7 +619,7 @@ public class PCEnhancer {
|
|||
}
|
||||
|
||||
if (getCreateSubclass()) {
|
||||
PCSubclassValidator val = new PCSubclassValidator(_meta, classNode, _managedType, _log, _fail);
|
||||
PCSubclassValidator val = new PCSubclassValidator(_meta, classNode, _log, _fail);
|
||||
val.assertCanSubclass();
|
||||
|
||||
_pc = _managedType.getProject().loadClass(toPCSubclassName(_managedType.getType()));
|
||||
|
|
|
@ -39,9 +39,6 @@ import org.apache.openjpa.meta.FieldMetaData;
|
|||
import org.apache.openjpa.util.UserException;
|
||||
import org.apache.xbean.asm9.tree.ClassNode;
|
||||
|
||||
import serp.bytecode.BCClass;
|
||||
import serp.bytecode.BCField;
|
||||
import serp.bytecode.BCMethod;
|
||||
|
||||
/**
|
||||
* <p>Validates that a given type meets the JPA contract, plus a few
|
||||
|
@ -86,18 +83,15 @@ public class PCSubclassValidator {
|
|||
|
||||
private final ClassMetaData meta;
|
||||
private final ClassNode classNode;
|
||||
private final BCClass bc;
|
||||
private final Log log;
|
||||
private final boolean failOnContractViolations;
|
||||
|
||||
private Collection errors;
|
||||
private Collection contractViolations;
|
||||
|
||||
public PCSubclassValidator(ClassMetaData meta, ClassNode classNode, BCClass bc, Log log,
|
||||
boolean enforceContractViolations) {
|
||||
public PCSubclassValidator(ClassMetaData meta, ClassNode classNode, Log log, boolean enforceContractViolations) {
|
||||
this.meta = meta;
|
||||
this.classNode = classNode;
|
||||
this.bc = bc;
|
||||
this.log = log;
|
||||
this.failOnContractViolations = enforceContractViolations;
|
||||
}
|
||||
|
@ -205,11 +199,8 @@ public class PCSubclassValidator {
|
|||
*/
|
||||
private Field checkGetterIsSubclassable(Method meth, FieldMetaData fmd) {
|
||||
checkMethodIsSubclassable(meth, fmd);
|
||||
BCField bcField = PCEnhancer.getReturnedField_old(getBCMethod(meth));
|
||||
Field field = PCEnhancer.getReturnedField(classNode, meth);
|
||||
|
||||
//X TODO remove
|
||||
PCEnhancer.assertSameField(field, bcField);
|
||||
Field field = PCEnhancer.getReturnedField(classNode, meth);
|
||||
|
||||
if (field == null) {
|
||||
addContractViolation(loc.get("subclasser-invalid-getter", fmd.getName()), fmd);
|
||||
|
@ -227,11 +218,8 @@ public class PCSubclassValidator {
|
|||
*/
|
||||
private Field checkSetterIsSubclassable(Method meth, FieldMetaData fmd) {
|
||||
checkMethodIsSubclassable(meth, fmd);
|
||||
BCField bcField = PCEnhancer.getAssignedField_old(getBCMethod(meth));
|
||||
Field field = PCEnhancer.getAssignedField(classNode, meth);
|
||||
|
||||
//X TODO remove
|
||||
PCEnhancer.assertSameField(field, bcField);
|
||||
Field field = PCEnhancer.getAssignedField(classNode, meth);
|
||||
|
||||
if (field == null) {
|
||||
addContractViolation(loc.get("subclasser-invalid-setter", fmd.getName()), fmd);
|
||||
|
@ -242,11 +230,6 @@ public class PCSubclassValidator {
|
|||
}
|
||||
}
|
||||
|
||||
private BCMethod getBCMethod(Method meth) {
|
||||
BCClass bc = this.bc.getProject().loadClass(meth.getDeclaringClass());
|
||||
return bc.getDeclaredMethod(meth.getName(), meth.getParameterTypes());
|
||||
}
|
||||
|
||||
private void checkMethodIsSubclassable(Method meth, FieldMetaData fmd) {
|
||||
String className = fmd.getDefiningMetaData().
|
||||
getDescribedType().getName();
|
||||
|
|
|
@ -34,7 +34,6 @@ import jakarta.persistence.AccessType;
|
|||
import jakarta.persistence.Basic;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.MappedSuperclass;
|
||||
import serp.bytecode.BCClass;
|
||||
import serp.bytecode.Project;
|
||||
|
||||
|
@ -84,7 +83,7 @@ public class TestSubclassValidator extends SingleEMFTestCase {
|
|||
ClassNode classNode = AsmHelper.readClassNode(EnhanceableGetterEntity.class.getClassLoader(), EnhanceableGetterEntity.class.getName());
|
||||
final BCClass bcClass = project.loadClass(EnhanceableGetterEntity.class.getName(), tempCl);
|
||||
final ClassMetaData meta = repos.getMetaData(tempCl.loadClass(EnhanceableGetterEntity.class.getName()), tempCl, false);
|
||||
PCSubclassValidator subclassValidator = new PCSubclassValidator(meta, classNode, bcClass, log, true);
|
||||
PCSubclassValidator subclassValidator = new PCSubclassValidator(meta, classNode, log, true);
|
||||
subclassValidator.assertCanSubclass();
|
||||
}
|
||||
|
||||
|
@ -92,7 +91,7 @@ public class TestSubclassValidator extends SingleEMFTestCase {
|
|||
ClassNode classNode = AsmHelper.readClassNode(UnenhancedPropertyAccess.class.getClassLoader(), UnenhancedPropertyAccess.class.getName());
|
||||
final BCClass bcClass = project.loadClass(UnenhancedPropertyAccess.class.getName(), tempCl);
|
||||
final ClassMetaData meta = repos.getMetaData(tempCl.loadClass(UnenhancedPropertyAccess.class.getName()), tempCl, false);
|
||||
PCSubclassValidator subclassValidator = new PCSubclassValidator(meta, classNode, bcClass, log, true);
|
||||
PCSubclassValidator subclassValidator = new PCSubclassValidator(meta, classNode, log, true);
|
||||
subclassValidator.assertCanSubclass();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue