Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
....
....
....
....
Originally posted by Sahir Shah:
Narayana Murthy,
Use the same method you use for creating your own packages eg:- package com.yourname.packagename;
For details refer to Bruce Eckels TIJ or
Patrick Naughton's The Complete Java Reference ( Chapter 9. Packages and Interfaces. Section - Understanding CLASSPATH.)
Asim Wagan,
I am not ready yet to post the code because I am not able to conclusively prove that you can get at the foundation classes private members. All I have managed so far is to fool the compiler. It has to run successfully and bushwhack one of the core classes. If I manage to do that I shall certainly post it here. If any of you guys have any suggestions please post it here. Many heads are better than one.
Rgds
Sahir
[This message has been edited by Sahir Shah (edited November 17, 2000).]
....
....
Originally posted by Sahir Shah:
Narayana Murthy,
Sorry. I might have misunderstood your question. The above post contains instructions on fooling the compiler. About what is
actually happening here. Well I dont know the full story yet. Apparently access modifiers are only checked at compile time in certain cases. So after you compile the caller class if the called class has been modified and the access modifier is now private the run time system ignores it. It isnt working with the java native classes right now. But it is worth a try.
Rgds
Sahir
Originally posted by Narayana Murthy:
Hello Ajith Kallambella
I have seen ur answer for this but i am not satisfied with that u are saying that the main method will work with private modifier also. Sun people are not considering this as a bug, then why in jls they given that public is must for main method can u elaborate this for me please .
[This message has been edited by Narayana Murthy (edited November 14, 2000).]
Alf.
SCJP2. Please Indent your code using UBB Code
00 access_flags
99 0000000000001001staticpublic
00 name_index
11b main
00 descriptor_index
12c ([Ljava/lang/StringV
00 attributes_count
11 1
00 access_flags
10a 0000000000001010staticprivate
00 name_index
11b main
00 descriptor_index
12c ([Ljava/lang/StringV
00 attributes_count
11 1
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
C:\Java\test>java Test2
Loading TypeField in java.net.URLClassLoader@601bb1
Copy TypeField.class to url1 and hit Enter
Loading ToLoad in java.net.URLClassLoader@ea2dfe
Loading TypeField in java.net.URLClassLoader@ea2dfe
Loading AccessingField in java.net.URLClassLoader@601bb1
Initializing ToLoad class
Exception in thread "main" java.lang.reflect.InvocationTargetException
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:324)
at Test2.main(Test2.java:20)
Caused by: java.lang.LinkageError: loader constraints violated when linking FieldType class
at AccessingField.printField(AccessingField.java:3)
... 5 more
SCJP2. Please Indent your code using UBB Code
SCJP2. Please Indent your code using UBB Code
Consider Paul's rocket mass heater. |