Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ private void asyncInvocationOfFlushSpi() {
flushTask.schedule(200);
}

// TODO this adds --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED
// XXX: we probably should not extends AbstractPreferences and do it all ourselfs
// including the firing of events. For the events delivery we could just reuse common
// RequestProcessor threads.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ public static boolean isWriteLocked(Document doc) {
} catch (NoSuchFieldException ex) {
throw new IllegalStateException(ex);
}
// TODO adds --add-opens=java.desktop/javax.swing.text=ALL-UNNAMED
f.setAccessible(true);
currWriterField = f;
}
Expand Down
3 changes: 3 additions & 0 deletions ide/xsl/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.8

test.config.stableBTD.includes=**/*Test.class

# at org.apache.tomcat.util.security.PrivilegedSetAccessControlContext.<clinit>(PrivilegedSetAccessControlContext.java:41)
test.jms.flags=--add-opens=java.base/java.lang=ALL-UNNAMED
7 changes: 7 additions & 0 deletions java/form/src/org/netbeans/modules/form/FormLAF.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ public static PreviewInfo initPreviewLaf(Class lafClass, ClassLoader formClassLo
!MetalLookAndFeel.class.equals(lafClass) && (lafToTheme.get(MetalLookAndFeel.class) == null)) {
lafToTheme.put(MetalLookAndFeel.class, MetalLookAndFeel.getCurrentTheme());
}
// adds
// --add-exports=java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED
// --add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
// --add-exports=java.desktop/com.apple.eio=ALL-UNNAMED
// --add-exports=java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED
LookAndFeel previewLookAndFeel = (LookAndFeel)lafClass.getDeclaredConstructor().newInstance();
if (previewLafIsMetal) {
MetalTheme theme = lafToTheme.get(lafClass);
Expand Down Expand Up @@ -209,6 +214,7 @@ private static void initialize() throws Exception {
}

java.lang.reflect.Method method = UIManager.class.getDeclaredMethod("getLAFState", new Class[0]); // NOI18N
// TODO adds --add-opens=java.desktop/javax.swing=ALL-UNNAMED
method.setAccessible(true);
Object lafState = method.invoke(null, new Object[0]);
method = lafState.getClass().getDeclaredMethod("setLookAndFeelDefaults", new Class[] {UIDefaults.class}); // NOI18N
Expand Down Expand Up @@ -373,6 +379,7 @@ private static void copyMultiUIDefaults(UIDefaults what, Map where) {
// in MultiUIDefaults in JDK 6 Update 10
try {
java.lang.reflect.Method method = Hashtable.class.getDeclaredMethod("getIterator", new Class[] {int.class}); // NOI18N
// TODO adds --add-opens=java.base/java.util=ALL-UNNAMED
method.setAccessible(true);
Object i = method.invoke(what, new Object[] {2/*Hashtable.ENTRIES*/});
if (i instanceof Iterator) {
Expand Down
1 change: 1 addition & 0 deletions java/form/src/org/netbeans/modules/form/HandleLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,7 @@ private static void paintDraggedComponent(Component comp, Graphics g, float opac
static {
try {
Field field = Component.class.getDeclaredField("valid"); // NOI18N
// TODO adds --add-opens=java.desktop/java.awt=ALL-UNNAMED
field.setAccessible(true);
componentValidField = field;
} catch (NoSuchFieldException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ public void report(JCDiagnostic diag) {
Env<AttrContext> result = attr.attributeAndCapture((JCTree) tree, env, (JCTree) to);
try {
Constructor<JavacScope> c = JavacScope.class.getDeclaredConstructor(Env.class);
// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
c.setAccessible(true);
return c.newInstance(result);
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@
*/
package org.netbeans.modules.java.source;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.ProtectionDomain;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.lang.model.SourceVersion;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.Opcodes;
import org.openide.modules.OnStart;

/**
*
Expand All @@ -51,57 +43,4 @@ public class NoJavacHelper {
public static boolean hasWorkingJavac() {
return HAS_WORKING_JAVAC;
}

// safety net if someone manages to start NB on JDK 8 with nb-javac uninstalled
@OnStart
public static class FixClasses implements Runnable {

@Override
public void run() {
if (!hasWorkingJavac()) {
String JavaVersion = System.getProperty("java.specification.version"); //NOI18N
boolean isJdkVer8OrBelow = true;
if (!JavaVersion.startsWith("1.")) { //NOI18N
isJdkVer8OrBelow = false;
}
if (isJdkVer8OrBelow) {
{
ClassWriter w = new ClassWriter(0);
w.visit(Opcodes.V1_8, Opcodes.ACC_ABSTRACT | Opcodes.ACC_PUBLIC, "com/sun/tools/javac/code/Scope$WriteableScope", null, "com/sun/tools/javac/code/Scope", null);
byte[] classData = w.toByteArray();

defineClass("com.sun.tools.javac.code.Scope$WriteableScope",
"com.sun.tools.javac.code.Scope",
classData);
}
{
ClassWriter w = new ClassWriter(0);
w.visit(Opcodes.V1_8, Opcodes.ACC_ABSTRACT | Opcodes.ACC_INTERFACE | Opcodes.ACC_PUBLIC, "javax/lang/model/element/ModuleElement", null, "java/lang/Object", new String[] {"javax/lang/model/element/Element"});
byte[] classData = w.toByteArray();

defineClass("javax.lang.model.element.ModuleElement",
"com.sun.tools.javac.code.Scope",
classData);
}
}
}
}

private void defineClass(String fqn, String injectToClass, byte[] classData) {
try {
Class<?> unsafeClass = Class.forName("sun.misc.Unsafe");
Field theUnsafe = unsafeClass.getDeclaredField("theUnsafe"); //NOI18N
theUnsafe.setAccessible(true);
Object unsafe = theUnsafe.get(null);

Class targetClass = Class.forName(injectToClass); //NOI18N

Method defineClass = unsafeClass.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class, ClassLoader.class, ProtectionDomain.class); //NOI18N
defineClass.invoke(unsafe, fqn, classData, 0, classData.length, targetClass.getClassLoader(), targetClass.getProtectionDomain()); //NOI18N
} catch (Throwable t) {
//ignore...
Logger.getLogger(NoJavacHelper.class.getName()).log(Level.WARNING, null, t);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,7 @@ public ReferenceTree Reference(ExpressionTree qualExpr, CharSequence member, Lis
paramTypesParam = lbl.toList();
}
Constructor<DCReference> c = DCReference.class.getDeclaredConstructor(String.class, JCExpression.class, JCTree.class, javax.lang.model.element.Name.class, List.class);
// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
c.setAccessible(true);
DCReference result = c.newInstance("", (JCTree.JCExpression) qualExpr, qualExpr == null ? null : ((JCTree.JCExpression) qualExpr).getTree(), member != null ? (com.sun.tools.javac.util.Name) names.fromString(member.toString()) : null, paramTypesParam);
result.pos = NOPOS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,14 @@ protected ParsingOutput compile(
List<Element> activeTypes = new ArrayList<>();
if (unit.getValue().jfo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
final PackageTree pt = unit.getKey().getPackage();
if (pt instanceof JCPackageDecl) {
final Element sym = ((JCPackageDecl)pt).packge;
if (pt instanceof JCPackageDecl decl) {
final Element sym = decl.packge;
if (sym != null)
activeTypes.add(sym);
}
} else {
for (Tree tree : unit.getKey().getTypeDecls()) {
if (tree instanceof JCTree) {
final JCTree jct = (JCTree)tree;
if (tree instanceof JCTree jct) {
if (jct.getTag() == JCTree.Tag.CLASSDEF) {
final Element sym = ((JCClassDecl)tree).sym;
if (sym != null)
Expand Down Expand Up @@ -480,7 +479,8 @@ private static void fallbackCopyExistingClassFiles(final Context context,
} catch (IOException | InterruptedException | ExecutionException ex) {
Exceptions.printStackTrace(ex);
}
}
}

private static void copyRecursively(FileObject source, File targetRoot, File target, Set<String> filter, FileManagerTransaction fmtx, List<File> copied) throws IOException {
if (source.isFolder()) {
if (target.exists() && !target.isDirectory()) {
Expand Down Expand Up @@ -1114,6 +1114,7 @@ private void clearTypeVar(Type.TypeVar tv) {
for (String boundName : boundNames) {
try {
Field bound = tv.getClass().getDeclaredField(boundName);
// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
bound.setAccessible(true);
bound.set(tv, error2Object((Type) bound.get(tv)));
} catch (IllegalAccessException | NoSuchFieldException | SecurityException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private static JCDiagnostic getJCDiagnostic(Diagnostic<?> d) {
} else if ("org.netbeans.modules.java.source.parsing.CompilationInfoImpl$DiagnosticListenerImpl$D".equals(d.getClass().getName())) {
try {
Field delegate = d.getClass().getDeclaredField("delegate");
// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
delegate.setAccessible(true);
return getJCDiagnostic((Diagnostic<?>) delegate.get(d));
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public class VanillaPartialReparser implements PartialReparser {
private final Method lineMapBuild;
private final boolean allowPartialReparse;

// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED and --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
@SuppressWarnings("LocalVariableHidesMemberVariable")
public VanillaPartialReparser() {
Field lazyDocCommentsTable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public JavacScope getScope(TreePath path) {
Method dupMethodTemp;

try {
// TODO this adds --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
basicHandlerFieldTemp = Check.class.getDeclaredField("basicHandler");
basicHandlerFieldTemp.setAccessible(true);
returnResultFieldTemp = AttrContext.class.getDeclaredField("returnResult");
Expand Down
1 change: 0 additions & 1 deletion nbbuild/jms-config/base.flags
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
--enable-native-access=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.lang.ref=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.security=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
Expand Down
5 changes: 0 additions & 5 deletions nbbuild/jms-config/compiler.flags
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
Expand Down
10 changes: 3 additions & 7 deletions nbbuild/jms-config/desktop.flags
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED
--add-opens=java.desktop/javax.swing=ALL-UNNAMED
--add-opens=java.desktop/java.awt=ALL-UNNAMED
--add-opens=java.desktop/java.awt.event=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.X11=ALL-UNNAMED
--add-opens=java.desktop/javax.swing.plaf.synth=ALL-UNNAMED
--add-opens=java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED
--add-opens=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
--add-opens=java.desktop/com.apple.laf=ALL-UNNAMED
--add-opens=java.desktop/sun.awt.im=ALL-UNNAMED
--add-exports=java.desktop/sun.awt=ALL-UNNAMED
--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED
--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED
--add-exports=java.desktop/sun.swing=ALL-UNNAMED
--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED
--add-exports=java.desktop/com.sun.java.swing.plaf.motif=ALL-UNNAMED
--add-exports=java.desktop/com.apple.eio=ALL-UNNAMED
--add-exports=java.desktop/com.sun.java.swing.plaf.gtk=ALL-UNNAMED
--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED
--add-exports=java.desktop/com.apple.laf=ALL-UNNAMED
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static Field getContextField() throws Exception {
} catch (NoSuchFieldException nsfe) { // IBM JDK1.5 has different field
ctx = AccessControlContext.class.getDeclaredField("domainsArray"); // NOI18N
}
// TODO adds --add-opens=java.base/java.security=ALL-UNNAMED
ctx.setAccessible(true);
context = ctx;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static synchronized void register() {
throw new Exception("No, or multiple, URLStreamHandler-valued fields in URL: " + candidates);
}
Field f = candidates.get(0);
// TODO adds -J--add-opens=java.base/java.net=ALL-UNNAMED
f.setAccessible(true);
originalJarHandler = (URLStreamHandler) f.get(new URL("jar:file:/sample.jar!/"));
LOG.log(Level.FINE, "found originalJarHandler: {0}", originalJarHandler);
Expand Down
Loading