You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Regis Xu (JIRA)" <ji...@apache.org> on 2009/01/22 09:11:59 UTC
[jira] Created: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
[eut][drlvm] Class.getMethod may return method of subtype
----------------------------------------------------------
Key: HARMONY-6077
URL: https://issues.apache.org/jira/browse/HARMONY-6077
Project: Harmony
Issue Type: Bug
Components: DRLVM
Affects Versions: 5.0M8
Reporter: Regis Xu
Fix For: 5.0M9
test case:
X.java:
import java.lang.reflect.*;
import p.*;
public class X {
static public void main(String args[]) {
Y y = new Y();
try {
Method foo = Y.class.getMethod("foo", (Class[]) null);
y.foo();
foo.invoke(y, (Object[]) null);
} catch (NoSuchMethodException e) {
// ignore
} catch (InvocationTargetException e) {
// ignore
} catch (IllegalAccessException e) {
System.out.print("FAILURE: IllegalAccessException");
}
}
}
Y.java
package p;
public class Y extends Z {
/* empty */
}
Z.java
package p;
class Z {
public void foo() {
System.out.println("SUCCESS"); //$NON-NLS-1$
}
}
run class X, RI and classlib with IBM VME has the same output:
SUCCESS
FAILURE: IllegalAccessException
while drlvm output:
SUCCESS
SUCCESS
after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Li Jing Qin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12679541#action_12679541 ]
Li Jing Qin commented on HARMONY-6077:
--------------------------------------
Hi guys, I am also investigating this issue. It seems the bug of RI 1.5 and RI 1.6 has the same behavior of ours. Here is the link: https://bugs.eclipse.org/bugs/show_bug.cgi?id=126712
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
> Fix For: 5.0M9
>
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678032#action_12678032 ]
Alexey Varlamov commented on HARMONY-6077:
------------------------------------------
No, such a fix is incorrect.
Apparently we face a bug in RI. Java Language Specification explicitly mentions similar scenario (section 8.2.1 of JLS 2nd edition).
My vote is to resolve this as non-bug difference (file a bug against EUT if needed to improve pass rate).
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
> Fix For: 5.0M9
>
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Alexey Varlamov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexey Varlamov resolved HARMONY-6077.
--------------------------------------
Resolution: Won't Fix
Fix Version/s: (was: 5.0M9)
Thanks for the link Li, it also provided relevant bugreport for RI [1]. Quite funny approach to fix reflection issues via javac compiler workarounds :)
Chunrong, why would you ever want to differentiate member accessibility rules between normal use and reflection? Anyway the API specs for reflection always refer to Java language access control. Thus resolving WONTFIX.
[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342411
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678221#action_12678221 ]
Chunrong Lai commented on HARMONY-6077:
---------------------------------------
I think that the section 15.12.4.3 "Check Accessibility of Type and Method" of JLS should be used/implemented here. If so I do not think we can do "full inspection of the hierarchy". :-)
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
> Fix For: 5.0M9
>
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676182#action_12676182 ]
Chunrong Lai commented on HARMONY-6077:
---------------------------------------
I investigated the issue and saw the test case gets pass if we add "public" modifier to class Z which is the declaring class of foo().
Although drlvm although regards non-public Z can not be accessed, it still regards the access is safe since Class Y (the runtime class of foo()) is public, with below code segments in java\lang\reflect\ReflectExporter.java (under vmcore\src\kernel_classes)
private boolean allowAccess(Class<?> callerClass, Class<?> declaringClass, Class<?> runtimeClass, int memberModifiers) {
if (hasSameTopLevelClass(declaringClass, callerClass)) return true;
if (Modifier.isPrivate(memberModifiers)) return false;
// check access to public members
if (Modifier.isPublic(memberModifiers)) {
if (allowClassAccess(declaringClass, callerClass)) return true; //not allow access in our test case case
// full inspection of the hierarchy
if (runtimeClass != declaringClass) {
do {
if (allowClassAccess(runtimeClass, callerClass) || hasSameTopLevelClass(runtimeClass, callerClass)) return true; // why drlvm can allow the invokation in the test case
} while ((runtimeClass = runtimeClass.getSuperclass()) != declaringClass);
}
return false;
}
......
}
The fix should be removing the allowClassAccess(runtimeClass, callerClass) from the "full inspection of the hierarchy " session or just removing the whole session.
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
> Fix For: 5.0M9
>
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may
return method of subtype
Posted by "Chunrong Lai (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12678206#action_12678206 ]
Chunrong Lai commented on HARMONY-6077:
---------------------------------------
hi, Alexey:
Please correct me if I am wrong.
The test case in HARMONY-6077 give two ways to run the methos, y.foo(); and foo.invoke(y, (Object[]) null); We see that Harmony(drlvm) and RI both succeed in the first case (y.foo();) as the section 8.2.1.4 "Accessing Members of Inaccessible Classes" of JLS mentions.
The problem and my suggested fix happens/targets in foo.invoke(y, (Object[]) null); I am not sure if the case is same as what mentions in section 8.2.1 of JLS.
> [eut][drlvm] Class.getMethod may return method of subtype
> ----------------------------------------------------------
>
> Key: HARMONY-6077
> URL: https://issues.apache.org/jira/browse/HARMONY-6077
> Project: Harmony
> Issue Type: Bug
> Components: DRLVM
> Affects Versions: 5.0M8
> Reporter: Regis Xu
> Fix For: 5.0M9
>
>
> test case:
> X.java:
> import java.lang.reflect.*;
> import p.*;
> public class X {
> static public void main(String args[]) {
> Y y = new Y();
> try {
> Method foo = Y.class.getMethod("foo", (Class[]) null);
> y.foo();
> foo.invoke(y, (Object[]) null);
> } catch (NoSuchMethodException e) {
> // ignore
> } catch (InvocationTargetException e) {
> // ignore
> } catch (IllegalAccessException e) {
> System.out.print("FAILURE: IllegalAccessException");
> }
> }
> }
> Y.java
> package p;
> public class Y extends Z {
> /* empty */
> }
> Z.java
> package p;
> class Z {
> public void foo() {
> System.out.println("SUCCESS"); //$NON-NLS-1$
> }
> }
> run class X, RI and classlib with IBM VME has the same output:
> SUCCESS
> FAILURE: IllegalAccessException
> while drlvm output:
> SUCCESS
> SUCCESS
> after debugging, I found foo is public void p.Z.foo()
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.