diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java index 6aaac815d1b..bc849f24af7 100644 --- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java +++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/messages/NLS.java @@ -19,8 +19,6 @@ package org.apache.lucene.queryparser.flexible.messages; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.text.MessageFormat; import java.util.HashMap; import java.util.Iterator; @@ -125,27 +123,22 @@ public class NLS { private static void load(Class clazz) { final Field[] fieldArray = clazz.getDeclaredFields(); - boolean isFieldAccessible = (clazz.getModifiers() & Modifier.PUBLIC) != 0; - // build a map of field names to Field objects final int len = fieldArray.length; Map fields = new HashMap<>(len * 2); for (int i = 0; i < len; i++) { fields.put(fieldArray[i].getName(), fieldArray[i]); - loadfieldValue(fieldArray[i], isFieldAccessible, clazz); + loadfieldValue(fieldArray[i], clazz); } } - private static void loadfieldValue(Field field, boolean isFieldAccessible, - Class clazz) { + private static void loadfieldValue(Field field, Class clazz) { int MOD_EXPECTED = Modifier.PUBLIC | Modifier.STATIC; int MOD_MASK = MOD_EXPECTED | Modifier.FINAL; if ((field.getModifiers() & MOD_MASK) != MOD_EXPECTED) return; // Set a value for this empty field. - if (!isFieldAccessible) - makeAccessible(field); try { field.set(null, field.getName()); validateMessage(field.getName(), clazz); @@ -178,21 +171,4 @@ public class NLS { // system } } - - /* - * Make a class field accessible - */ - private static void makeAccessible(final Field field) { - if (System.getSecurityManager() == null) { - field.setAccessible(true); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - field.setAccessible(true); - return null; - } - }); - } - } } diff --git a/lucene/tools/junit4/tests.policy b/lucene/tools/junit4/tests.policy index f5729d3e797..2052657df31 100644 --- a/lucene/tools/junit4/tests.policy +++ b/lucene/tools/junit4/tests.policy @@ -57,8 +57,6 @@ grant { permission java.lang.RuntimePermission "getStackTrace"; // needed for mock filesystems in tests permission java.lang.RuntimePermission "fileSystemProvider"; - // needed by queryparser/ NLS., TODO clean this up: - permission java.lang.RuntimePermission "accessClassInPackage.sun.util"; // needed for test of IOUtils.spins (maybe it can be avoided) permission java.lang.RuntimePermission "getFileStoreAttributes"; // analyzers/uima: needed by UIMA message localization... (?)