summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-08-14 17:09:20 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-08-14 17:09:20 +0000
commitb956b6fde3a1a3e485956f1075412fa8a52e8fe9 (patch)
treed9dccf9d2dff11e382090552528f3caddf7f198e /src/main
parenta4aa08342e5afe143df42a641a23efd24a0cafb0 (diff)
Removed support for Storable definition to accept Repository in constructor.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/amazon/carbonado/gen/StorableGenerator.java46
-rw-r--r--src/main/java/com/amazon/carbonado/info/StorableIntrospector.java23
2 files changed, 12 insertions, 57 deletions
diff --git a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
index 41ba8b9..388b52a 100644
--- a/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
+++ b/src/main/java/com/amazon/carbonado/gen/StorableGenerator.java
@@ -21,9 +21,7 @@ package com.amazon.carbonado.gen;
import java.lang.annotation.Annotation;
import java.lang.ref.Reference;
import java.lang.ref.SoftReference;
-import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -451,8 +449,8 @@ public final class StorableGenerator<S extends Storable> {
final int supportParam = 0;
MethodInfo mi = mClassFile.addConstructor(Modifiers.PROTECTED, params);
CodeBuilder b = new CodeBuilder(mi);
-
- addInvokeSuperConstructor(b, supportParam);
+ b.loadThis();
+ b.invokeSuperConstructor(null);
//// this.support = support
b.loadThis();
@@ -468,8 +466,8 @@ public final class StorableGenerator<S extends Storable> {
final int wrappedStorableParam = 1;
MethodInfo mi = mClassFile.addConstructor(Modifiers.PUBLIC, params);
CodeBuilder b = new CodeBuilder(mi);
-
- addInvokeSuperConstructor(b, wrappedSupportParam);
+ b.loadThis();
+ b.invokeSuperConstructor(null);
//// this.wrappedSupport = wrappedSupport
b.loadThis();
@@ -1962,42 +1960,6 @@ public final class StorableGenerator<S extends Storable> {
}
/**
- * Generates code to invoke super class constructor with no arguments or a
- * Repository.
- */
- private void addInvokeSuperConstructor(CodeBuilder b, final int supportParam) {
- // Look for constructor that accepts a Repository.
-
- boolean passRepo = false;
- {
- for (Constructor c : mStorableType.getDeclaredConstructors()) {
- int modifiers = c.getModifiers();
- if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) {
- continue;
- }
- if (c.getParameterTypes().length == 1) {
- if (c.getParameterTypes()[0] == Repository.class) {
- passRepo = true;
- break;
- }
- }
- }
- }
-
- b.loadThis();
-
- if (passRepo) {
- b.loadLocal(b.getParameter(supportParam));
- b.invokeInterface(StorableSupport.class.getName(), "getRootRepository",
- TypeDesc.forClass(Repository.class), null);
- b.invokeSuperConstructor(new TypeDesc[] {TypeDesc.forClass(Repository.class)});
- } else {
- // Assume no-arg constructor.
- b.invokeSuperConstructor(null);
- }
- }
-
- /**
* If GEN_WRAPPED, generates a method implementation which delgates to the
* WrappedSupport. Also clears join property state if called method
* returns normally.
diff --git a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
index 133e175..b7f7744 100644
--- a/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
+++ b/src/main/java/com/amazon/carbonado/info/StorableIntrospector.java
@@ -62,7 +62,6 @@ import com.amazon.carbonado.Nullable;
import com.amazon.carbonado.Independent;
import com.amazon.carbonado.PrimaryKey;
import com.amazon.carbonado.Query;
-import com.amazon.carbonado.Repository;
import com.amazon.carbonado.Sequence;
import com.amazon.carbonado.Storable;
import com.amazon.carbonado.Version;
@@ -491,35 +490,29 @@ public class StorableIntrospector {
checkTypeParameter(errorMessages, type);
- // If type is a class, it must have a public/protected constructor that
- // takes no arguments or a Repository. If overloaded, the constructor
- // with the Repository parameter is preferred by the code generator.
+ // If type is a class, it must have a public or protected no-arg
+ // constructor.
if (!type.isInterface()) {
Constructor[] ctors = type.getDeclaredConstructors();
findCtor: {
for (Constructor c : ctors) {
- modifiers = c.getModifiers();
- if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) {
- continue;
- }
if (c.getParameterTypes().length == 0) {
- break findCtor;
- }
- if (c.getParameterTypes().length == 1) {
- if (c.getParameterTypes()[0] == Repository.class) {
- break findCtor;
+ modifiers = c.getModifiers();
+ if (!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) {
+ errorMessages.add("Cannot call constructor: " + c);
}
+ break findCtor;
}
}
if (type.getEnclosingClass() == null) {
errorMessages.add
("Class must have a public or protected constructor " +
- "that takes no arguments or a Repository");
+ "that accepts no arguments");
} else {
errorMessages.add
("Inner class must have a public or protected constructor " +
- "that takes no arguments or a Repository");
+ "that accepts no arguments");
}
}
}