Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #29949

Re: What counts as a reference?

From Steven Simpson <ss@domain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: What counts as a reference?
Date 2014-09-12 15:47 +0100
Organization A noiseless patient Spider
Message-ID <ikdbeb-vcb.ln1@s.simpson148.btinternet.com> (permalink)
References <mgt41aluh04qirbq20lrin09lbanr01shs@4ax.com>

Show all headers | View raw


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

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

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

csiph-web