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

Y

Yao Qi

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.

--
Yao Qi <[email protected]> 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)
 
T

Thomas Fritsch

Yao said:
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
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;
 
L

Lew

Yao said:
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.
 
Y

Yao Qi

Lew said:
Yao said:
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.

--
Yao Qi <[email protected]> GNU/Linux Developer
http://duewayqi.googlepages.com/

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

Lew

Yao said:
Lew said:
Yao said:
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 [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>
 
Y

Yao Qi

Thomas Fritsch said:
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.

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.
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;

It works on my IBM JDK as well. Thanks.

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

--
Yao Qi <[email protected]> GNU/Linux Developer
http://duewayqi.googlepages.com/

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

Lew

Yao said:
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.
 
Y

Yao Qi

Lew said:
Yao said:
Lew said:
Yao Qi wrote:
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 [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?

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".
 
T

Thomas Fritsch

Lew said:
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[][][], ...
 
A

A. Bolmarcich

Yao said:
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.
 
Y

Yao Qi

Thomas Fritsch said:
Lew said:
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[][][],
...

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.

--
Yao Qi <[email protected]> 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top