Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

-verbose:class and java.lang.Object[]

Thread view: 
Yao Qi - 12 Jun 2007 14:23 GMT
I tried the option -verbose:class to JVM, and I am little confused by
the output.

IMO, -verbose:class will tell us what classes are loaded by JVM,
however, in the output, we find some arrays, such as,

class load: java/lang/Object
...
class load: java/io/ObjectStreamField[]
class load: java/lang/Class[]
class load: java/lang/Object[]                                                                        
...
class load: java/lang/Thread[]
class load: java/lang/ThreadGroup[]
class load: java/lang/ThreadGroup$ChildrenGroupsLock
class load: java/lang/ThreadGroup$ChildrenThreadsLock
class load: java/lang/Thread$ThreadLock
class load: java/security/cert/Certificate
class load: java/security/cert/Certificate[]
class load: java/lang/System                                                                          

Does this mean java.lang.Object and java.lang.Object[] are different
class?  I try to use Class.forName("java.lang.Object[]") to verify my
idea, but I find that there is no such class.

Any thought on this?  I get the result on IBM JDK.

Signature

Yao Qi <qiyaoltc@gmail.com>    GNU/Linux Developer
http://duewayqi.googlepages.com/

"Of course, in Perl culture, almost nothis is prohibited. My feeling is that the rest of the world already has plenty of perfectly good prohibitions, so why invent more?"

 -- Larry Wall (Open Sources, 1999 O'Reilly and Associates)

Thomas Fritsch - 12 Jun 2007 15:24 GMT
> I tried the option -verbose:class to JVM, and I am little confused by
> the output.
[quoted text clipped - 16 lines]
> class load: java/security/cert/Certificate[]
> class load: java/lang/System
On my Sun JDK I get
[Opened /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
...
[Loaded java.lang.Object from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.io.Serializable from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.Comparable from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.CharSequence from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.String from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.Class from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.Cloneable from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.ClassLoader from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.System from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[Loaded java.lang.Throwable from /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
...
It seems that Sun's Java decides not to trace the array classes.

> Does this mean java.lang.Object and java.lang.Object[] are different
> class?
Yes they are definitely different classes.
As far as I guess: class java.lang.Object is really loaded from a file
"java/lang/Object.class", but class java.lang.Object[] is probably
generated on the fly.
> I try to use Class.forName("java.lang.Object[]") to verify my
> idea, but I find that there is no such class.
Try
  Class c = Class.forName("[Ljava.lang.Object;");
instead (it works on my Sun JDK).
By the way: a more obvious syntax is
  Class c = java.lang.Object[].class;

> Any thought on this?  I get the result on IBM JDK.

Signature

Thomas

Yao Qi - 12 Jun 2007 17:49 GMT
> On my Sun JDK I get
> [Opened /usr/lib/SunJava2-1.4.2/jre/lib/rt.jar]
[quoted text clipped - 22 lines]
> "java/lang/Object.class", but class java.lang.Object[] is probably
> generated on the fly.

Yeah.  I never find the actual class file for java.lang.Object[], so it
may be generated when loading classes.

I am thinking why there is no such class file corresponding to array
class.  Still have no idea on this.

>> I try to use Class.forName("java.lang.Object[]") to verify my
>> idea, but I find that there is no such class.
[quoted text clipped - 3 lines]
> By the way: a more obvious syntax is
>    Class c = java.lang.Object[].class;

It works on my IBM JDK as well.  Thanks.

I also find that the super class of these array classes is java.lang.Object.

Signature

Yao Qi <qiyaoltc@gmail.com>    GNU/Linux Developer
http://duewayqi.googlepages.com/

Music in the soul can be heard by the universe.
        -- Lao Tsu

Lew - 12 Jun 2007 17:58 GMT
> I am thinking why there is no such class file corresponding to array
> class.  Still have no idea on this.

Because it's built into the language and the JVM.

Signature

Lew

Thomas Fritsch - 12 Jun 2007 18:41 GMT
>> I am thinking why there is no such class file corresponding to array
>> class.  Still have no idea on this.
>
> Because it's built into the language and the JVM.

and because (if the JVM implementors would have decided to load array
classes from class files) there would be an infinite number of class files:
i.e. not only class String[], but also classes String[][], String[][][], ...

Signature

Thomas

Yao Qi - 13 Jun 2007 10:09 GMT
>>> I am thinking why there is no such class file corresponding to array
>>> class.  Still have no idea on this.
[quoted text clipped - 6 lines]
> i.e. not only class String[], but also classes String[][], String[][][],
> ...

Yeah.  You are right.

I don't clear about the JVM internals, but I think these array classes
are generated on the fly.

If I am correct on this, could I instrument the on-the-fly-generated
array classes?

I used ClassFileLoadHook in my JVM TI agent, but the agent is NOT
notified by JVM when array class is loaded, or generated.

Signature

Yao Qi <qiyaoltc@gmail.com>    GNU/Linux Developer
http://duewayqi.googlepages.com/

Great accomplishment seems imperfect,
Yet it does not outlive its usefulness.
Great fullness seems empty,
Yet cannot be exhausted.

Great straightness seems twisted.
Great intelligence seems stupid.
Great eloquence seems awkward.

Movement overcomes cold.
Stillness overcomes heat.
Stillness and tranquillity set things in order in the universe.

Lew - 12 Jun 2007 15:45 GMT
> Does this mean java.lang.Object and java.lang.Object[] are different
> class?  I try to use Class.forName("java.lang.Object[]") to verify my
> idea, but I find that there is no such class.

Yes, the array is a different class from the non-array.

Signature

Lew

Yao Qi - 12 Jun 2007 17:33 GMT
>> Does this mean java.lang.Object and java.lang.Object[] are different
>> class?  I try to use Class.forName("java.lang.Object[]") to verify my
>> idea, but I find that there is no such class.
>
> Yes, the array is a different class from the non-array.

Any document available on this issue?  I read JVM specification, but I
do not find any thing relative to this.  It is only said that (from In side
the JVM), "array is full-feathered object", but the class information is
not mentioned.

Signature

Yao Qi <qiyaoltc@gmail.com>    GNU/Linux Developer
http://duewayqi.googlepages.com/

Don't worry.  Life's too long.
        -- Vincent Sardi, Jr.

Lew - 12 Jun 2007 17:47 GMT
>>> Does this mean java.lang.Object and java.lang.Object[] are different
>>> class?  I try to use Class.forName("java.lang.Object[]") to verify my
[quoted text clipped - 5 lines]
> the JVM), "array is full-feathered [sic] object", but the class information is
> not mentioned.

I do not understand your issue.  The quote you provide (it's "full-fledged",
not "full-feathered" [1]) seems to answer your original question.  What
knowledge do you seek?

Arrays are defined for Java in the Java Language Specification (JLS).  Any
other documentation you find will perforce be based on that.
<http://java.sun.com/docs/books/jls/third_edition/html/arrays.html>

[1] "Fledged" originally meant "feathered" but its meaning has widened.
Metaphorically, "full(y)-fledged" ("completely feathered") means "completely
qualified" or "entirely realized".
<http://en.wiktionary.org/wiki/full-fledged>

Signature

Lew

Yao Qi - 12 Jun 2007 18:08 GMT
>>>> Does this mean java.lang.Object and java.lang.Object[] are different
>>>> class?  I try to use Class.forName("java.lang.Object[]") to verify
[quoted text clipped - 12 lines]
> "full-fledged", not "full-feathered" [1]) seems to answer your original
> question.  What knowledge do you seek?

Sorry.  It is "full-fledged", instead of "full-feathered".
My brain does not work now, time to go to bed. :)

> Arrays are defined for Java in the Java Language Specification (JLS).
> Any other documentation you find will perforce be based on that.
> <http://java.sun.com/docs/books/jls/third_edition/html/arrays.html>

Emm, that is what I want to find.

> [1] "Fledged" originally meant "feathered" but its meaning has
> widened. Metaphorically, "full(y)-fledged" ("completely feathered")
> means "completely qualified" or "entirely realized".
> <http://en.wiktionary.org/wiki/full-fledged>

Thanks for you nice explanation on "fledged" and "feathered".

Signature

Yao Qi <qiyaoltc@gmail.com>    GNU/Linux Developer
http://duewayqi.googlepages.com/

A. Bolmarcich - 12 Jun 2007 19:54 GMT
>> Does this mean java.lang.Object and java.lang.Object[] are different
>> class?  I try to use Class.forName("java.lang.Object[]") to verify my
>> idea, but I find that there is no such class.
>
> Yes, the array is a different class from the non-array.

And the name of array class is not name of the element type followed
by "[]".  For an array of Object you want to use:

 Class.forName("[Ljava.lang.Object;")

See the API documentation of the getName() method of Class at

 http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Class.html#getName()

for a description of the names of array classes.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.