public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/27352]  New: SecurityManager.checkPermission() called unnecessarily
@ 2006-04-28 14:53 aph at gcc dot gnu dot org
  2006-04-28 15:16 ` [Bug libgcj/27352] " aph at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: aph at gcc dot gnu dot org @ 2006-04-28 14:53 UTC (permalink / raw)
  To: java-prs

With the attached testcase, SecurityManager.checkPermission() is called three
times when it should only be called once.  In genral, we make far too many
invocations of SecurityManager.checkPermission().


-- 
           Summary: SecurityManager.checkPermission() called unnecessarily
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcj
        AssignedTo: aph at gcc dot gnu dot org
        ReportedBy: aph at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
@ 2006-04-28 15:16 ` aph at gcc dot gnu dot org
  2006-04-28 15:18 ` aph at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aph at gcc dot gnu dot org @ 2006-04-28 15:16 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from aph at gcc dot gnu dot org  2006-04-28 15:16 -------
Created an attachment (id=11344)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11344&action=view)
Test case.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
  2006-04-28 15:16 ` [Bug libgcj/27352] " aph at gcc dot gnu dot org
@ 2006-04-28 15:18 ` aph at gcc dot gnu dot org
  2006-05-01  6:41 ` csm at gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aph at gcc dot gnu dot org @ 2006-04-28 15:18 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from aph at gcc dot gnu dot org  2006-04-28 15:18 -------
The output of this test should be something like:

java.lang.Throwable
        at MySecurityManager.checkPermission(t.java:33)
        at java.lang.Class.getClassLoader(Class.java:580)
        at trial.x(trial.java:5)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
        at java.lang.reflect.Method.invoke(Method.java:386)
        at t.main(t.java:57)
class MySecurityManager called with (java.lang.RuntimePermission
getClassLoader)
sun.misc.Launcher$AppClassLoader@42a5e121

but we produce

java.lang.Throwable
   at MySecurityManager.checkPermission (t.java:33)
   at java.lang.Class.getClassLoader (natClass.cc:126)
   at java.lang.Class.getPackage (Class.java:466)
   at java.lang.Class.memberAccessCheck (Class.java:906)
   at java.lang.Class.newInstance (natClass.cc:641)
   at t.main (t.java:54)
class MySecurityManager called with (java.lang.RuntimePermission getClassLoader
)
java.lang.Throwable
   at MySecurityManager.checkPermission (t.java:33)
   at java.lang.Class.getClassLoader (natClass.cc:126)
   at java.lang.Class.getPackage (Class.java:466)
   at java.lang.Class.memberAccessCheck (Class.java:906)
   at java.lang.Class.getMethod (Class.java:513)
   at t.main (t.java:56)
class MySecurityManager called with (java.lang.RuntimePermission getClassLoader
)
java.lang.Throwable
   at MySecurityManager.checkPermission (t.java:33)
   at java.lang.Class.getClassLoader (natClass.cc:126)
   at trial.x (trial.java:5)
   at java.lang.reflect.Method.invoke (natMethod.cc:182)
   at t.main (t.java:57)
class MySecurityManager called with (java.lang.RuntimePermission getClassLoader
)
gnu.gcj.runtime.SystemClassLoader{urls=[file:./],
parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}


-- 

aph at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-04-28 15:18:30
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
  2006-04-28 15:16 ` [Bug libgcj/27352] " aph at gcc dot gnu dot org
  2006-04-28 15:18 ` aph at gcc dot gnu dot org
@ 2006-05-01  6:41 ` csm at gnu dot org
  2006-05-02 10:08 ` aph at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: csm at gnu dot org @ 2006-05-01  6:41 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from csm at gnu dot org  2006-05-01 06:41 -------
It looks like methods internal to Class need to bypass the security manager
when getting the class loader, or should be doing that lookup in a
`doPriviliged' block, right?

Does Classpath itself suffer from this?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-05-01  6:41 ` csm at gnu dot org
@ 2006-05-02 10:08 ` aph at gcc dot gnu dot org
  2006-05-04 18:45 ` aph at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aph at gcc dot gnu dot org @ 2006-05-02 10:08 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from aph at gcc dot gnu dot org  2006-05-02 10:08 -------
The real reason is that we want the actual caller of
SecurityManager.checkPermission(), but we're walking up the stack to the user
code that called Class.newInstance() Class.getMethod().  This problem is as far
as I'm aware unique to gcj, but it might be worth testing on other VMs.

I have a patch for this that I'm testing.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-05-02 10:08 ` aph at gcc dot gnu dot org
@ 2006-05-04 18:45 ` aph at gcc dot gnu dot org
  2006-05-16  1:03 ` mckinlay at redhat dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: aph at gcc dot gnu dot org @ 2006-05-04 18:45 UTC (permalink / raw)
  To: java-prs



------- Comment #5 from aph at gcc dot gnu dot org  2006-05-04 18:45 -------
Subject: Bug 27352

Author: aph
Date: Thu May  4 18:44:53 2006
New Revision: 113532

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113532
Log:
2006-05-04  Andrew Haley  <aph@redhat.com>

        * class.c (make_field_value): Always build_address_of fdecl if
        there is an initializer.

2006-05-03  Andrew Haley  <aph@redhat.com>

        PR libgcj/27352
        * expr.c (maybe_rewrite_invocation): New function.
        (rewrite_arglist_getclass): Likewise.
        (rules): New.
        (expand_invoke): Call maybe_rewrite_invocation.
        * parse.y (patch_invoke): Likewise.
        * java-tree.h: (maybe_rewrite_invocation): New function.

2006-05-03  Andrew Haley  <aph@redhat.com>

        PR libgcj/27352
        * java/lang/Class.java (getClassLoader(Class)): New.
        forName(String, Class): New.
        * java/lang/natClass.cc (getClassLoader(Class)): New.

2006-05-02  Andrew Haley  <aph@redhat.com>

        * prims.cc (_Jv_NewMultiArray): Check for phantom class.


Modified:
    trunk/gcc/java/ChangeLog
    trunk/gcc/java/class.c
    trunk/gcc/java/expr.c
    trunk/gcc/java/java-tree.h
    trunk/gcc/java/parse.y
    trunk/libjava/ChangeLog
    trunk/libjava/java/lang/Class.h
    trunk/libjava/java/lang/Class.java
    trunk/libjava/java/lang/natClass.cc
    trunk/libjava/prims.cc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-05-04 18:45 ` aph at gcc dot gnu dot org
@ 2006-05-16  1:03 ` mckinlay at redhat dot com
  2006-05-17 15:10 ` bryce at gcc dot gnu dot org
  2006-05-17 15:18 ` mckinlay at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: mckinlay at redhat dot com @ 2006-05-16  1:03 UTC (permalink / raw)
  To: java-prs



------- Comment #6 from mckinlay at redhat dot com  2006-05-16 01:03 -------
I've posted a suggested fix here:

http://gcc.gnu.org/ml/java-patches/2006-q2/msg00168.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-05-16  1:03 ` mckinlay at redhat dot com
@ 2006-05-17 15:10 ` bryce at gcc dot gnu dot org
  2006-05-17 15:18 ` mckinlay at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: bryce at gcc dot gnu dot org @ 2006-05-17 15:10 UTC (permalink / raw)
  To: java-prs



------- Comment #7 from bryce at gcc dot gnu dot org  2006-05-17 15:10 -------
Subject: Bug 27352

Author: bryce
Date: Wed May 17 15:09:57 2006
New Revision: 113863

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113863
Log:
        PR libgcj/27352
        * java/lang/Class.java (getClassLoaderInternal): New method.
        (forName (String, Class)): Use getClassLoaderInternal.
        (getPackage): Likewise.
        (getResource): Likewise.
        (getResourceAsStream): Likewise.
        (desiredAssertionStatus): Likewise.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/java/lang/Class.java


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/27352] SecurityManager.checkPermission() called unnecessarily
  2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2006-05-17 15:10 ` bryce at gcc dot gnu dot org
@ 2006-05-17 15:18 ` mckinlay at redhat dot com
  7 siblings, 0 replies; 9+ messages in thread
From: mckinlay at redhat dot com @ 2006-05-17 15:18 UTC (permalink / raw)
  To: java-prs



------- Comment #8 from mckinlay at redhat dot com  2006-05-17 15:18 -------
Fixed


-- 

mckinlay at redhat dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27352


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-05-17 15:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-28 14:53 [Bug libgcj/27352] New: SecurityManager.checkPermission() called unnecessarily aph at gcc dot gnu dot org
2006-04-28 15:16 ` [Bug libgcj/27352] " aph at gcc dot gnu dot org
2006-04-28 15:18 ` aph at gcc dot gnu dot org
2006-05-01  6:41 ` csm at gnu dot org
2006-05-02 10:08 ` aph at gcc dot gnu dot org
2006-05-04 18:45 ` aph at gcc dot gnu dot org
2006-05-16  1:03 ` mckinlay at redhat dot com
2006-05-17 15:10 ` bryce at gcc dot gnu dot org
2006-05-17 15:18 ` mckinlay at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).