commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Sklyut <Dmitry_Skl...@orcom.com>
Subject RE: Re[2]: Jakarta Commons:Digester - Getting IllegalAccessExcept ion
Date Tue, 01 Jul 2003 14:57:01 GMT
Why would this be reported to SUN?  As far as I know this is a correct
behavior of the Java VM.

If the class is not public and you can only use it from the class in the
same package.  This is a regular scoping issue.

Example:

package my;

class MyExample {
	public void foo() {
	}
}

package my.test;

public class Test {
	public static void main(String[] arg) {
		// my example is a package level class in the my package
		MyExample exmpl = new MyExample();
		exmpl.foo();
	}	
}

This code will not compile because MyExample is not visible to the my.test
package Test class.

Reflection API gives you a set of tools to execute the methods of the
arbitrary classes dynamically during run time, but it is still govern by the
language specification restriction.

So if it is true during compile time, it should be true during runtime with
the reflection API.  There are ways to circumvent that, but those involve
permissions and security checking.

You best bet would be reading up on the java.lang.reflect package java doc,
and http://java.sun.com/docs/books/tutorial/reflect/index.html/ Reflection
API trail.  This should be enough to get you started.

Dmitry

-----Original Message-----
From: Anton Tagunov [mailto:atagunov@mail.cnt.ru]
Sent: Tuesday, July 01, 2003 10:42 AM
To: Jakarta Commons Users List
Subject: Re[2]: Jakarta Commons:Digester - Getting
IllegalAccessException


Hello Dmitry!

DS> There is an issue when invoking public methods contained in a default
access
DS> superclass. Reflection locates these methods fine and correctly assigns
them
DS> as public. However, an IllegalAccessException is thrown if the method is
DS> invoked.

Has this been reported to Sun?

-Anton


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message