# HG changeset patch # User Tom Rodriguez # Date 1450325900 28800 # Node ID 94a6bb5a58f2c17cdc1d0a885a412cea02606653 # Parent 8c8c7e8b7ab2b19ab1949ee2e602e2067dc1e27c OptionValues should be public or package diff -r 8c8c7e8b7ab2 -r 94a6bb5a58f2 jvmci/jdk.vm.ci.options.processor/src/jdk/vm/ci/options/processor/OptionProcessor.java --- a/jvmci/jdk.vm.ci.options.processor/src/jdk/vm/ci/options/processor/OptionProcessor.java Wed Dec 16 16:08:05 2015 -0800 +++ b/jvmci/jdk.vm.ci.options.processor/src/jdk/vm/ci/options/processor/OptionProcessor.java Wed Dec 16 20:18:20 2015 -0800 @@ -79,6 +79,10 @@ processingEnv.getMessager().printMessage(Kind.ERROR, "Option field must be static", element); return; } + if (element.getModifiers().contains(Modifier.PRIVATE)) { + processingEnv.getMessager().printMessage(Kind.ERROR, "Option field cannot be private", element); + return; + } Option annotation = element.getAnnotation(Option.class); assert annotation != null; @@ -108,6 +112,10 @@ processingEnv.getMessager().printMessage(Kind.ERROR, "Option field must be static", element); return; } + if (field.getModifiers().contains(Modifier.PRIVATE)) { + processingEnv.getMessager().printMessage(Kind.ERROR, "Option field cannot be private", element); + return; + } String help = annotation.help(); if (help.length() != 0) { @@ -187,7 +195,6 @@ String desc = OptionDescriptor.class.getSimpleName(); - boolean needPrivateFieldAccessor = false; int i = 0; Collections.sort(info.options); @@ -203,8 +210,7 @@ String name = option.name; String optionValue; if (option.field.getModifiers().contains(Modifier.PRIVATE)) { - needPrivateFieldAccessor = true; - optionValue = "field(" + option.declaringClass + ".class, \"" + option.field.getSimpleName() + "\")"; + throw new InternalError(); } else { optionValue = option.declaringClass + "." + option.field.getSimpleName(); } @@ -230,8 +236,7 @@ for (OptionInfo option : info.options) { String optionValue; if (option.field.getModifiers().contains(Modifier.PRIVATE)) { - needPrivateFieldAccessor = true; - optionValue = "field(" + option.declaringClass + ".class, \"" + option.field.getSimpleName() + "\")"; + throw new InternalError(); } else { optionValue = option.declaringClass + "." + option.field.getSimpleName(); } @@ -248,17 +253,6 @@ out.println(" // CheckStyle: resume line length check"); out.println(" return options.iterator();"); out.println(" }"); - if (needPrivateFieldAccessor) { - out.println(" private static " + OptionValue.class.getSimpleName() + " field(Class declaringClass, String fieldName) {"); - out.println(" try {"); - out.println(" java.lang.reflect.Field field = declaringClass.getDeclaredField(fieldName);"); - out.println(" field.setAccessible(true);"); - out.println(" return (" + OptionValue.class.getSimpleName() + ") field.get(null);"); - out.println(" } catch (Exception e) {"); - out.println(" throw (InternalError) new InternalError().initCause(e);"); - out.println(" }"); - out.println(" }"); - } out.println("}"); } }