Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Steven Simpson Newsgroups: comp.lang.java.programmer Subject: Re: What counts as a reference? Date: Fri, 12 Sep 2014 15:47:14 +0100 Organization: A noiseless patient Spider Lines: 59 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: mx05.eternal-september.org; posting-host="8d2122d2008ee80f5e54b979e3340738"; logging-data="13588"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zh9yIEW5xnTGY7wcieqeQwkA+Z+JL3Xw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 In-Reply-To: Cancel-Lock: sha1:477QSryZuAQxv9Vw5pK91azUv8A= Xref: csiph.com comp.lang.java.programmer:29949 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."":()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 #13 = Utf8 ()V #14 = Utf8 Code #15 = Utf8 LineNumberTable #16 = Utf8 #17 = Utf8 SourceFile #18 = Utf8 IsARef.java #19 = NameAndType #12:#13 // "":()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