JDK-5002910 : (reflect spec) ReflectPermission doesn't specify throws for name = null | ""
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2004-02-25
  • Updated: 2017-05-16
  • Resolved: 2004-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b42Fixed
Related Reports
Relates :  
Relates :  
Description

Name: iaR10016			Date: 02/25/2004


Filed By       : J2SE-SQA [###@###.###
JDK            : JDK1.5.0-b39, JDK1.5.0-b38, JDK1.4.2-b28
JCK            : JCK1.5-runtime (b12a)
Platform[s]    : all
switch/Mode    : default
JCK test owner : http://javaweb.eng/jck/usr/owners.jto
Falling test   :
   api/java_lang/reflect/ReflectPermission/index.html#ReflectPermission [ReflectPermission1001, ReflectPermission1002]

JCK1.5-runtime api/java_lang/reflect/ReflectPermission/index.html#ReflectPermission test
fails using JDK1.5.0-b39 on all platforms with "java.lang.IllegalArgumentException: name can't be empty"
exception.

This test was excluded in JCK1.4a and it is in the latest JCK1.5 known failure list because of the
Specification bug 4274149 marked as integrated in JDK1.5.0-b28.

However, it seems like the bug 4274149 was not fully integrated: bug 4269279 (a duplicate of #4274149)
is still reproducible in the latest tiger builds, ReflectPermission class API Specification still does not specify
ReflectPermission constructors behavior if "name" parameter is null:
...
public ReflectPermission(String name)
     Constructs a ReflectPermission with the specified name.
     Parameters:
         name - the name of the ReflectPermission

public ReflectPermission(String name, String actions)
     Constructs a ReflectPermission with the specified name and actions. The actions should be null; they are ignored.
     Parameters:
         name - the name of the ReflectPermission
         actions - should be null.
...

Please, see bugs 4269279, 4274149 for more details.

Test source location:
=====================
/java/re/jck/1.5/promoted/beta/b12a/binaries/JCK-runtime-15/tests/api/java_lang/reflect/ReflectPermission/ReflectPermissionTests.java

jtr file location:
==================
/net/jtgb4u4c.sfbay/export/sail15/results.2/tiger/b39/jck15/sparc/sol10_sparc_cde_client_d64_esa_linux-8/workDir/api/java_lang/reflect/ReflectPermission/index_ReflectPermission.jtr

How to reproduce:
=================
Run the following script (you may need to change its variables)

--- script start ---
#!/bin/sh

#Paths in Java Software:
JDK="/java/re/jdk/1.5.0/promoted/all/b39/binaries/solaris-sparc"
JCK="/java/re/jck/1.5/promoted/beta/b12a/binaries/JCK-runtime-15"

#Alternative paths outside Java Software
#JDK="/net/koori.sfbay/onestop/jdk/1.5.0/promoted/all/b39/binaries/solaris-sparc"
#JCK="/net/koori.sfbay/onestop/jck/1.5/promoted/beta/b12a/binaries/JCK-runtime-15"

#Alternative paths for the NSK site:
#JCK="/net/linux-15/export/home/java/jck1.5/JCK-runtime-15"
#JDK="/net/linux-15/export/home/java/jdk1.5.0/sparc"

export CLASSPATH="$JCK/classes:$JCK/lib/javatest.jar"

echo `cat $JCK/build.txt | grep JCK_VERSION` `cat $JCK/build.txt | grep JCK_BUILD`
$JDK/bin/java -showversion     javasoft.sqe.tests.api.java.lang.reflect.ReflectPermission.ReflectPermissionTests     -TestCaseID ReflectPermission1001 ReflectPermission1002
--- script end ---

Test output:
============
JCK_VERSION=1.5 JCK_BUILD_ID=b12a
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b39)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b39, mixed mode)

java.lang.IllegalArgumentException: name can't be empty
     at java.security.BasicPermission.init(BasicPermission.java:87)
     at java.security.BasicPermission.<init>(BasicPermission.java:120)
     at java.lang.reflect.ReflectPermission.<init>(ReflectPermission.java:62)
     at javasoft.sqe.tests.api.java.lang.reflect.ReflectPermission.ReflectPermissionTests.ReflectPermission1001(ReflectPermissionTests.java:89)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:494)
     at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:399)
     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:127)
     at javasoft.sqe.tests.api.java.lang.reflect.ReflectPermission.ReflectPermissionTests.main(ReflectPermissionTests.java:24)
ReflectPermission1001: Failed. Test case throws exception: java.lang.IllegalArgumentException: name can't be empty
java.lang.IllegalArgumentException: name can't be empty
     at java.security.BasicPermission.init(BasicPermission.java:87)
     at java.security.BasicPermission.<init>(BasicPermission.java:138)
     at java.lang.reflect.ReflectPermission.<init>(ReflectPermission.java:73)
     at javasoft.sqe.tests.api.java.lang.reflect.ReflectPermission.ReflectPermissionTests.ReflectPermission1002(ReflectPermissionTests.java:181)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:494)
     at javasoft.sqe.javatest.lib.MultiTest.invokeTestCase(MultiTest.java:399)
     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:195)
     at javasoft.sqe.javatest.lib.MultiTest.run(MultiTest.java:127)
     at javasoft.sqe.tests.api.java.lang.reflect.ReflectPermission.ReflectPermissionTests.main(ReflectPermissionTests.java:24)
ReflectPermission1002: Failed. Test case throws exception: java.lang.IllegalArgumentException: name can't be empty
STATUS:Failed.test cases: 2; all failed; first test case failure: ReflectPermission1001

Specific machine info:
======================
Hostname: linux-16
OS: Windows XP Pro
Hostname: linux-22
OS: RedHat Linux 9.0 (GNOME)
Hostname: linux-4
OS: Turbo Linux 7.0 (GNOME)
Hostname: linux-8
OS: Solaris 10 (sparc) (CDE)

======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b42 tiger-beta2 VERIFIED IN: tiger-beta2
14-06-2004

SUGGESTED FIX *** /tmp/geta7436 Wed Feb 25 15:06:00 2004 --- ReflectPermission.java Wed Feb 25 14:57:59 2004 *************** *** 57,62 **** --- 57,68 ---- * Constructs a ReflectPermission with the specified name. * * @param name the name of the ReflectPermission + * + * @throws NullPointerException + * If <tt>name</tt> is <tt>null</tt> + * + * @throws IllegalArgumentException + * If <tt>name</tt> is empty */ public ReflectPermission(String name) { super(name); *************** *** 67,73 **** * The actions should be null; they are ignored. * * @param name the name of the ReflectPermission ! * @param actions should be null. */ public ReflectPermission(String name, String actions) { super(name, actions); --- 73,86 ---- * The actions should be null; they are ignored. * * @param name the name of the ReflectPermission ! * ! * @param actions should be null ! * ! * @throws NullPointerException ! * If <tt>name</tt> is <tt>null</tt> ! * ! * @throws IllegalArgumentException ! * If <tt>name</tt> is empty */ public ReflectPermission(String name, String actions) { super(name, actions);
11-06-2004

EVALUATION It appears that the two ReflectioPermission constructors have never specified what exceptions will be thrown for name == null or name = "". Here is the historic behaviour of these methods on these two inputs: ReflectPerm(name) RP(name, actions) null "" null "" ----------------- ----------------- 12 IAE no ex IAE no ex 122 NPE no ex NPE no ex 13 NPE IAE NPE IAE 131 NPE IAE NPE IAE 14 NPE IAE NPE IAE 141 NPE IAE NPE IAE 142 NPE IAE NPE IAE 15 NPE IAE NPE IAE import java.lang.reflect.ReflectPermission; public class Test { public static void main(String [] args) { try { new ReflectPermission(null); System.out.println("FAILED null"); } catch (NullPointerException x) { System.out.println("passed"); } catch (Exception x) { System.out.println("FAILED " + x.getClass().getName()); } try { new ReflectPermission(""); System.out.println("FAILED \"\""); } catch (IllegalArgumentException x) { System.out.println("passed"); } catch (Exception x) { System.out.println("FAILED " + x.getClass().getName()); } try { new ReflectPermission(null, null); System.out.println("FAILED null"); } catch (NullPointerException x) { System.out.println("passed"); } catch (Exception x) { System.out.println("FAILED " + x.getClass().getName()); } try { new ReflectPermission("", null); System.out.println("FAILED \"\""); } catch (IllegalArgumentException x) { System.out.println("passed"); } catch (Exception x) { System.out.println("FAILED " + x.getClass().getName()); } } } These methods do nothing expect delegate to constructors in the parent class java.security.BasicPermission. We should document the existing behaviour. -- iag@sfbay 2004-02-25
25-02-2004