Configurable enum limit
This commit is contained in:
@@ -107,6 +107,9 @@ public class GlobalConfiguration {
|
||||
public static boolean directlyDefineTypes = true;
|
||||
|
||||
public final static boolean interceptReflection = true;
|
||||
|
||||
// max number of values before we prevent them being reloaded (the clinit rewrite blows the codesize limit)
|
||||
public static int enumLimit = 1000;
|
||||
|
||||
public static boolean reloadMessages = false;// can be forced on for testing
|
||||
|
||||
@@ -210,6 +213,9 @@ public class GlobalConfiguration {
|
||||
isCaching = kv.substring(equals + 1).equalsIgnoreCase("true");
|
||||
} else if (key.equals("debugplugins")) {
|
||||
debugPlugins = true;
|
||||
}
|
||||
else if(key.equals("enumlimit")) {
|
||||
enumLimit = toInt(kv.substring(equals+1),enumLimit);
|
||||
} else if (key.equals("profile")) {
|
||||
profile = kv.substring(equals + 1);
|
||||
} else if (key.equals("cacheDir")) {
|
||||
@@ -356,6 +362,12 @@ public class GlobalConfiguration {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Alternative route for specifying values
|
||||
value = System.getProperty("springloaded.enumlimit");
|
||||
if (value != null) {
|
||||
enumLimit = toInt(value,enumLimit);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
System.err.println("Unexpected problem reading global configuration setting:" + t.toString());
|
||||
t.printStackTrace();
|
||||
@@ -363,6 +375,14 @@ public class GlobalConfiguration {
|
||||
debugplugins = debugPlugins;
|
||||
}
|
||||
|
||||
private static int toInt(String value, int defaultValue) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (NumberFormatException nfe) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
public final static boolean isJava18orHigher;
|
||||
|
||||
static {
|
||||
|
||||
@@ -778,13 +778,13 @@ public class MethodInvokerRewriter {
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
return;
|
||||
}
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > 1000) {
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > GlobalConfiguration.enumLimit) {
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
return;
|
||||
}
|
||||
rewriteGETSTATIC(opcode, owner, name, desc);
|
||||
} else if (opcode == PUTSTATIC) {
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > 1000) {
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > GlobalConfiguration.enumLimit) {
|
||||
super.visitFieldInsn(opcode, owner, name, desc);
|
||||
return;
|
||||
}
|
||||
@@ -1335,7 +1335,7 @@ public class MethodInvokerRewriter {
|
||||
if (name.charAt(0) == '<') {
|
||||
// constructor
|
||||
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > 1000 && owner.equals(slashedclassname)) {
|
||||
if (isEnum && isClinitOrEnumInit && fieldcount > GlobalConfiguration.enumLimit && owner.equals(slashedclassname)) {
|
||||
super.visitMethodInsn(opcode, owner, name, desc);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -864,7 +864,7 @@ public class ReloadableType {
|
||||
|
||||
public byte[] getBytes() {
|
||||
RewriteClassAdaptor rca = (RewriteClassAdaptor) cv;
|
||||
if (rca.isEnum && rca.fieldcount > 1000) {
|
||||
if (rca.isEnum && rca.fieldcount > GlobalConfiguration.enumLimit) {
|
||||
// that is too many fields, marking this as not reloadable
|
||||
// TODO ...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user