summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES.txt1
-rw-r--r--src/main/java/com/amazon/carbonado/gen/StorableGenerator.java46
-rw-r--r--src/main/java/com/amazon/carbonado/info/StorableIntrospector.java23
3 files changed, 12 insertions, 58 deletions
diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 010f8b8..fc21234 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -23,7 +23,6 @@ Carbonado change history
- Added support for derived properies.
- Enhanced query engine to optimize for covering indexes.
- Added methods to access Storable properties by name.
-- Allow Storable definition to accept Repository in constructor.
- JDBCRepository allows more column types to be represented by Strings -- numbers and dates.
- JDBCRepository supports char and Character property if column is char type of length 1.
- JDBCRepository allows non-null column to be @Nullable if also @Independent.
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");
}
}
}