RFR - 8129956: jaxp: CodeSource.getLocation() might return null

Paul Sandoz paul.sandoz at oracle.com
Mon Jun 29 09:13:03 UTC 2015


On Jun 29, 2015, at 10:35 AM, Daniel Fuchs <daniel.fuchs at oracle.com> wrote:

> On 29/06/15 10:06, Paul Sandoz wrote:
>> That's odd i would of expected it to work. Here's Joe's patch to changes in the JDK:
>> 
>>   http://cr.openjdk.java.net/~darcy/8078467.0/jdk.patch
>> 
>> (Search for "new PrivilegedAction" in the patch.)
>> 
>> e.g. an expression in java.io.ObjectInputStream:
>> 
>> http://hg.openjdk.java.net/jdk9/dev/jdk/file/93ced310c728/src/java.base/share/classes/java/io/ObjectInputStream.java#l1265
>> 
>> private static boolean auditSubclass(final Class<?> subcl) {
>>     Boolean result = AccessController.doPrivileged(
>>         new PrivilegedAction<>() {
>>             public Boolean run() {
> 
> Hmmm... Strange indeed. Maybe I did a mistake - or maybe it had to do
> with using return directly without passing through an intermediary
> Boolean variable?
> 

I modified some of those doPriv blocks in:

src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java

and it compiled without issue:

diff -r 17b47acf5b3d src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java
--- a/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java	Tue Jun 23 19:50:10 2015 +0200
+++ b/src/java.xml/share/classes/javax/xml/validation/SecuritySupport.java	Mon Jun 29 11:11:26 2015 +0200
@@ -42,9 +42,9 @@


     ClassLoader getContextClassLoader() {
-        return (ClassLoader)
-        AccessController.doPrivileged(new PrivilegedAction() {
-            public Object run() {
+        return
+        AccessController.doPrivileged(new PrivilegedAction<>() {
+            public ClassLoader run() {
                 ClassLoader cl = null;
                 //try {
                 cl = Thread.currentThread().getContextClassLoader();
@@ -57,9 +57,9 @@
     }

     String getSystemProperty(final String propName) {
-        return (String)
-            AccessController.doPrivileged(new PrivilegedAction() {
-                public Object run() {
+        return
+            AccessController.doPrivileged(new PrivilegedAction<>() {
+                public String run() {
                     return System.getProperty(propName);
                 }
             });



> NetBeans didn't suggest replacing with diamonds either - which it
> usually does - but then maybe it was busy scanning classpath ;-)
> 

This is a relatively new 9-based language feature, so i don't expect the IDEs have caught up yet (IntelliJ 15 EAP has not for this feature, or for the try-with-resources enhancement IIRC).

Paul.



More information about the core-libs-dev mailing list