Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #29947 > unrolled thread
| Started by | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| First post | 2014-09-11 21:30 -0700 |
| Last post | 2014-09-12 21:53 -0700 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.java.programmer
What counts as a reference? Roedy Green <see_website@mindprod.com.invalid> - 2014-09-11 21:30 -0700
Re: What counts as a reference? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-09-12 11:19 +0100
Re: What counts as a reference? Steven Simpson <ss@domain.invalid> - 2014-09-12 15:47 +0100
Re: What counts as a reference? Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2014-09-12 21:53 -0700
| From | Roedy Green <see_website@mindprod.com.invalid> |
|---|---|
| Date | 2014-09-11 21:30 -0700 |
| Subject | What counts as a reference? |
| Message-ID | <mgt41aluh04qirbq20lrin09lbanr01shs@4ax.com> |
I a suspicion that Java/genjar/Jet includes classes it does not really need to. I have not done full experiments. I suspect an @see counts as a reference I suspect that private static X x; counts as a reference even if there is no mention of X or x elsewhere. I wonder if anyone has ever dug into this or has read something on the topic. -- Roedy Green Canadian Mind Products http://mindprod.com There are only two industries that refer to their customers as users. ~ Edward Tufte (born: 1942 age: 72)
[toc] | [next] | [standalone]
| From | "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> |
|---|---|
| Date | 2014-09-12 11:19 +0100 |
| Message-ID | <IKednXFCcoPKV4_JnZ2dnUVZ7q6dnZ2d@bt.com> |
| In reply to | #29947 |
Roedy Green wrote:
> I suspect that private static X x; counts as a reference even if there
> is no mention of X or x elsewhere.
From memory of the JVM spec (not the Java spec), the reference "private static
X x;" must cause the containing class to fail to load (I forget at what stage)
if there is no class X.
It's a long time since the JVM spec was part of my daily reading, though.
-- chris
[toc] | [prev] | [next] | [standalone]
| From | Steven Simpson <ss@domain.invalid> |
|---|---|
| Date | 2014-09-12 15:47 +0100 |
| Message-ID | <ikdbeb-vcb.ln1@s.simpson148.btinternet.com> |
| In reply to | #29947 |
On 12/09/14 05:30, Roedy Green wrote:
> I suspect an @see counts as a reference
> I suspect that private static X x; counts as a reference even if there
> is no mention of X or x elsewhere.
Use javap to check:
$ cat IsARef.java
/**
* This class is pointless.
*
* @see Referenced
*/
public class IsARef {
private static Runnable x;
private static Class<?> y = Iterable.class;
}
$ cat Referenced.java
public class Referenced { }
$ javac IsARef.java
$ javap -verbose IsARef
[...]
Constant pool:
#1 = Methodref #5.#19 // java/lang/Object."<init>":()V
#2 = Class #20 // java/lang/Iterable
#3 = Fieldref #4.#21 // IsARef.y:Ljava/lang/Class;
#4 = Class #22 // IsARef
#5 = Class #23 // java/lang/Object
#6 = Utf8 x
#7 = Utf8 Ljava/lang/Runnable;
#8 = Utf8 y
#9 = Utf8 Ljava/lang/Class;
#10 = Utf8 Signature
#11 = Utf8 Ljava/lang/Class<*>;
#12 = Utf8 <init>
#13 = Utf8 ()V
#14 = Utf8 Code
#15 = Utf8 LineNumberTable
#16 = Utf8 <clinit>
#17 = Utf8 SourceFile
#18 = Utf8 IsARef.java
#19 = NameAndType #12:#13 // "<init>":()V
#20 = Utf8 java/lang/Iterable
#21 = NameAndType #8:#9 // y:Ljava/lang/Class;
#22 = Utf8 IsARef
#23 = Utf8 java/lang/Object
[...]
My understanding is that the only classes needed at runtime are those
listed in the constant pool under "Class" (right?), of which there are
only three above. One of them is to the defined class itself, one is a
reference to the base class, and the other is for the class literal for
Iterable. The @see has had no effect. Names of Runnable and Class (the
types of the two static fields) only exist in member signatures.
--
ss at comp dot lancs dot ac dot uk
[toc] | [prev] | [next] | [standalone]
| From | Kevin McMurtrie <mcmurtrie@pixelmemory.us> |
|---|---|
| Date | 2014-09-12 21:53 -0700 |
| Message-ID | <mcmurtrie-4AEC22.21530012092014@news.sonic.net> |
| In reply to | #29947 |
In article <mgt41aluh04qirbq20lrin09lbanr01shs@4ax.com>, Roedy Green <see_website@mindprod.com.invalid> wrote: > I a suspicion that Java/genjar/Jet includes classes it does not really > need to. > I have not done full experiments. > > I suspect an @see counts as a reference > I suspect that private static X x; counts as a reference even if there > is no mention of X or x elsewhere. > > I wonder if anyone has ever dug into this or has read something on the > topic. @see, the JavaDoc annotation, has no influence on source code compilation. Only a JavaDoc compiler uses it. java.lang.annotation.Annotation (the @interface declarations) with RetentionPolicy of RUNTIME are loaded on demand for each class from bytecode then held in the java.lang.Class instance. Unused static fields hold a reference to a class unless the source code compiler has been explicitly configured to remove them. The reference begins when the class is initialized for use. Referencing a class does not initialize the class; only using the class initializes it. Therefore, a class referenced only by an unused static field may be loaded but not initialized. A class that is loaded but not initialized will not load any other classes. Loading old Apache spaghetti without this trick would be pretty much impossible. -- I will not see posts from astraweb, theremailer, dizum, or google because they host Usenet flooders.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web