This is an automated email from the ASF dual-hosted git repository.
jtulach pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 0d766ac checkMemberAccess method and other inaccessible classes as of
JDK11
0d766ac is described below
commit 0d766ac6a7ab0bcb7005360382c3a1de45d89375
Author: Jaroslav Tulach <[email protected]>
AuthorDate: Wed Jan 2 14:23:19 2019 +0100
checkMemberAccess method and other inaccessible classes as of JDK11
---
.../src/sun/net/spi/nameservice/NameService.java | 29 ++++++++++++++++
.../startup/layers/CountingSecurityManager.java | 37 ++++++++++++++++++--
.../modules/netbinox/CountingSecurityManager.java | 39 ++++++++++++++++++++--
.../propertysheet/EditorDisplayerTest.java | 7 ----
.../propertysheet/PropertyPanelInDialogTest.java | 8 -----
.../propertysheet/RendererDisplayerTest.java | 7 ----
platform/openide.util.enumerations/build.xml | 4 +++
7 files changed, 105 insertions(+), 26 deletions(-)
diff --git
a/platform/core.network/test/unit/src/sun/net/spi/nameservice/NameService.java
b/platform/core.network/test/unit/src/sun/net/spi/nameservice/NameService.java
new file mode 100644
index 0000000..0af1c31
--- /dev/null
+++
b/platform/core.network/test/unit/src/sun/net/spi/nameservice/NameService.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sun.net.spi.nameservice;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+/** Fake interface for compilation on JDK11 and more.
+ */
+public interface NameService {
+ public InetAddress[] lookupAllHostAddr(String host) throws
UnknownHostException;
+ public String getHostByAddr(byte[] addr) throws UnknownHostException;
+}
diff --git
a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
index 0e6bf79..3fcde0d 100644
---
a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
+++
b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java
@@ -85,10 +85,39 @@ final class CountingSecurityManager extends SecurityManager
implements Callable<
static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
- System.getSecurityManager().checkMemberAccess(null, maxCount);
+ System.getSecurityManager().checkPermission(new
MaxCountCheck(maxCount, "MaxCountCheck"));
System.getProperties().remove("counting.reflection.whitelist");
}
+ private static final class MaxCountCheck extends Permission {
+ final int maxCount;
+
+ MaxCountCheck(int maxCount, String name) {
+ super(name);
+ this.maxCount = maxCount;
+ }
+
+ @Override
+ public boolean implies(Permission permission) {
+ return false;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.hashCode();
+ }
+
+ @Override
+ public String getActions() {
+ return "MaxCountCheck";
+ }
+ }
+
@Override
public String toString() {
return msgs.toString();
@@ -126,6 +155,11 @@ final class CountingSecurityManager extends
SecurityManager implements Callable<
@Override
public void checkPermission(Permission p) {
+ if (p instanceof MaxCountCheck) {
+ checkMemberAccess(null, ((MaxCountCheck) p).maxCount);
+ return;
+ }
+
if (isDisabled()) {
return;
}
@@ -227,7 +261,6 @@ final class CountingSecurityManager extends SecurityManager
implements Callable<
}
private final Map<Class,Who> members = Collections.synchronizedMap(new
HashMap<Class, Who>());
- @Override
public void checkMemberAccess(Class<?> clazz, int which) {
if (clazz == null) {
assertMembers(which);
diff --git
a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java
b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java
index bb888e5..b73f929 100644
---
a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java
+++
b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java
@@ -79,10 +79,41 @@ final class CountingSecurityManager extends SecurityManager
implements Callable<
static void assertReflection(int maxCount, String whitelist) {
System.setProperty("counting.reflection.whitelist", whitelist);
- System.getSecurityManager().checkMemberAccess(null, maxCount);
+ System.getSecurityManager().checkPermission(new
MaxCountPerm(maxCount));
System.getProperties().remove("counting.reflection.whitelist");
}
+ private static final class MaxCountPerm extends Permission {
+
+ final int maxCount;
+
+ public MaxCountPerm(int maxCount) {
+ super("MaxCountPerm");
+ this.maxCount = maxCount;
+ }
+
+ @Override
+ public boolean implies(Permission permission) {
+ return this == permission;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return this == obj;
+ }
+
+ @Override
+ public int hashCode() {
+ return System.identityHashCode(this);
+ }
+
+ @Override
+ public String getActions() {
+ return getName();
+ }
+
+ }
+
@Override
public String toString() {
return msgs.toString();
@@ -120,6 +151,10 @@ final class CountingSecurityManager extends
SecurityManager implements Callable<
@Override
public void checkPermission(Permission p) {
+ if (p instanceof MaxCountPerm) {
+ checkMemberAccess(null, ((MaxCountPerm) p).maxCount);
+ return;
+ }
if (isDisabled()) {
return;
}
@@ -210,7 +245,7 @@ final class CountingSecurityManager extends SecurityManager
implements Callable<
}
private final Map<Class,Who> members = Collections.synchronizedMap(new
HashMap<Class, Who>());
- @Override
+
public void checkMemberAccess(Class<?> clazz, int which) {
if (clazz == null) {
assertMembers(which);
diff --git
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/EditorDisplayerTest.java
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/EditorDisplayerTest.java
index d108ea3..ca05437 100644
---
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/EditorDisplayerTest.java
+++
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/EditorDisplayerTest.java
@@ -19,7 +19,6 @@
package org.openide.explorer.propertysheet;
-import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -571,12 +570,6 @@ public class EditorDisplayerTest extends NbTestCase {
}
- private static class PseudoWindowsLookAndFeel extends WindowsLookAndFeel {
- public boolean isSupportedLookAndFeel() {
- return true;
- }
- }
-
public class TagsEditor extends PropertyEditorSupport implements
ExPropertyEditor {
PropertyEnv env;
String[] tags;
diff --git
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/PropertyPanelInDialogTest.java
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/PropertyPanelInDialogTest.java
index c9bcb3b..e507afe 100644
---
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/PropertyPanelInDialogTest.java
+++
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/PropertyPanelInDialogTest.java
@@ -19,7 +19,6 @@
package org.openide.explorer.propertysheet;
-import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
@@ -667,13 +666,6 @@ public class PropertyPanelInDialogTest extends NbTestCase {
}
}
-
- private static class PseudoWindowsLookAndFeel extends WindowsLookAndFeel {
- public boolean isSupportedLookAndFeel() {
- return true;
- }
- }
-
public class TagsEditor extends PropertyEditorSupport implements
ExPropertyEditor {
PropertyEnv env;
String[] tags;
diff --git
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/RendererDisplayerTest.java
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/RendererDisplayerTest.java
index 4c9b2a9..dca82c1 100644
---
a/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/RendererDisplayerTest.java
+++
b/platform/openide.explorer/test/unit/src/org/openide/explorer/propertysheet/RendererDisplayerTest.java
@@ -19,7 +19,6 @@
package org.openide.explorer.propertysheet;
-import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FlowLayout;
@@ -523,12 +522,6 @@ public class RendererDisplayerTest extends NbTestCase {
}
- private static class PseudoWindowsLookAndFeel extends WindowsLookAndFeel {
- public boolean isSupportedLookAndFeel() {
- return true;
- }
- }
-
public class TagsEditor extends PropertyEditorSupport implements
ExPropertyEditor {
PropertyEnv env;
String[] tags;
diff --git a/platform/openide.util.enumerations/build.xml
b/platform/openide.util.enumerations/build.xml
index 7fa277b..be9bbfd 100644
--- a/platform/openide.util.enumerations/build.xml
+++ b/platform/openide.util.enumerations/build.xml
@@ -34,6 +34,10 @@
</copy>
</target>
+ <target name="-do-junit" unless="is.jdk9">
+ <antcall target="projectized-common.-do-junit"/>
+ </target>
+
<target name="do-unit-test-build" unless="is.jdk9">
<antcall target="projectized-common.do-unit-test-build"/>
</target>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists