From commits-return-57313-apmail-harmony-commits-archive=harmony.apache.org@harmony.apache.org Tue Feb 24 04:38:23 2009 Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 95712 invoked from network); 24 Feb 2009 04:38:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Feb 2009 04:38:23 -0000 Received: (qmail 28882 invoked by uid 500); 24 Feb 2009 04:38:22 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 28860 invoked by uid 500); 24 Feb 2009 04:38:22 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 28851 invoked by uid 99); 24 Feb 2009 04:38:22 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Feb 2009 20:38:22 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Feb 2009 04:38:22 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id EEB67234C48D for ; Mon, 23 Feb 2009 20:38:01 -0800 (PST) Message-ID: <783281464.1235450281976.JavaMail.jira@brutus> Date: Mon, 23 Feb 2009 20:38:01 -0800 (PST) From: "Chunrong Lai (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6077) [eut][drlvm] Class.getMethod may return method of subtype In-Reply-To: <1096447609.1232611919759.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on 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.