91 92 static { 93 ignore("javax/tools/ToolProvider", "instance"); 94 ignore("com/sun/tools/javah/JavahTask", "versionRB"); 95 ignore("com/sun/tools/classfile/Dependencies$DefaultFilter", "instance"); 96 ignore("com/sun/tools/javap/JavapTask", "versionRB"); 97 ignore("com/sun/tools/doclets/formats/html/HtmlDoclet", "docletToStart"); 98 ignore("com/sun/tools/javac/util/JCDiagnostic", "fragmentFormatter"); 99 ignore("com/sun/tools/javac/util/JavacMessages", "defaultBundle", "defaultMessages"); 100 ignore("com/sun/tools/javac/file/JRTIndex", "sharedInstance"); 101 ignore("com/sun/tools/javac/main/JavaCompiler", "versionRB"); 102 ignore("com/sun/tools/javac/code/Type", "moreInfo"); 103 ignore("com/sun/tools/javac/util/SharedNameTable", "freelist"); 104 ignore("com/sun/tools/javac/util/Log", "useRawMessages"); 105 106 // The following static fields are used for caches of information obtained 107 // by reflective lookup, to avoid explicit references that are not available 108 // when running javac on JDK 8. 109 ignore("com/sun/tools/javac/util/ModuleHelper", 110 "addExportsMethod", "getModuleMethod", "getUnnamedModuleMethod"); 111 ignore("com/sun/tools/javac/util/ModuleWrappers$ConfigurationHelper", 112 "resolveRequiresAndUsesMethod", "configurationClass"); 113 ignore("com/sun/tools/javac/util/ModuleWrappers$LayerHelper", 114 "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass"); 115 ignore("com/sun/tools/javac/util/ModuleWrappers$ModuleFinderHelper", 116 "emptyMethod", "moduleFinderInterface", "ofMethod"); 117 118 119 } 120 121 private final List<String> errors = new ArrayList<>(); 122 123 public static void main(String[] args) { 124 try { 125 new DetectMutableStaticFields().run(); 126 } catch (Exception ex) { 127 throw new AssertionError("Exception during test execution: " + ex, ex); 128 } 129 } 130 131 private void run() 132 throws 133 IOException, 134 ConstantPoolException, 135 InvalidDescriptor, 136 URISyntaxException { 137 138 JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); | 91 92 static { 93 ignore("javax/tools/ToolProvider", "instance"); 94 ignore("com/sun/tools/javah/JavahTask", "versionRB"); 95 ignore("com/sun/tools/classfile/Dependencies$DefaultFilter", "instance"); 96 ignore("com/sun/tools/javap/JavapTask", "versionRB"); 97 ignore("com/sun/tools/doclets/formats/html/HtmlDoclet", "docletToStart"); 98 ignore("com/sun/tools/javac/util/JCDiagnostic", "fragmentFormatter"); 99 ignore("com/sun/tools/javac/util/JavacMessages", "defaultBundle", "defaultMessages"); 100 ignore("com/sun/tools/javac/file/JRTIndex", "sharedInstance"); 101 ignore("com/sun/tools/javac/main/JavaCompiler", "versionRB"); 102 ignore("com/sun/tools/javac/code/Type", "moreInfo"); 103 ignore("com/sun/tools/javac/util/SharedNameTable", "freelist"); 104 ignore("com/sun/tools/javac/util/Log", "useRawMessages"); 105 106 // The following static fields are used for caches of information obtained 107 // by reflective lookup, to avoid explicit references that are not available 108 // when running javac on JDK 8. 109 ignore("com/sun/tools/javac/util/ModuleHelper", 110 "addExportsMethod", "getModuleMethod", "getUnnamedModuleMethod"); 111 ignore("com/sun/tools/javac/util/JDK9Wrappers$Configuration", 112 "resolveRequiresAndUsesMethod", "configurationClass"); 113 ignore("com/sun/tools/javac/util/JDK9Wrappers$Layer", 114 "bootMethod", "defineModulesWithOneLoaderMethod", "configurationMethod", "layerClass"); 115 ignore("com/sun/tools/javac/util/JDK9Wrappers$ModuleFinder", 116 "moduleFinderClass", "ofMethod"); 117 ignore("com/sun/tools/javac/util/JDK9Wrappers$ServiceLoaderHelper", 118 "loadMethod"); 119 } 120 121 private final List<String> errors = new ArrayList<>(); 122 123 public static void main(String[] args) { 124 try { 125 new DetectMutableStaticFields().run(); 126 } catch (Exception ex) { 127 throw new AssertionError("Exception during test execution: " + ex, ex); 128 } 129 } 130 131 private void run() 132 throws 133 IOException, 134 ConstantPoolException, 135 InvalidDescriptor, 136 URISyntaxException { 137 138 JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); |