You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Kristian Rosenvold <kr...@gmail.com> on 2015/11/25 08:11:35 UTC

Why can't dependency plugin "see" statics /and staticimports

I poked around in the depdenedncy analyzer code to see if I could make
it "see" the following code:

Module 1:
public class Test2 {
    public static final int AZAZ = 42;
}

Module 2:

import foo.Test2;

public class BarMain
{
    public static void main(String[] args) {
        System.out.println("AZ " + Test2.AZAZ);
    }
}

Isn't this possible to detect or am I just a total n00b with asm ??


Kristian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Anders Hammar <an...@hammar.net>.
I've similar issues with the analyze. There are unused imports in the
source code (lazy devs) which aren't seen by the analyzer. Haven't looked
into the byte code, but guess it's the same issue as here.

/Anders

On Thu, Nov 26, 2015 at 9:25 AM, Kristian Rosenvold <
kristian.rosenvold@gmail.com> wrote:

> What I still dont understand is;
>
> the string might be inlined, but the "import" still seems to be
> visible in the bytecode. Shouldn't dependency:analyze consider this a
> "usage" ?
>
> Kristian
>
>
> 2015-11-25 10:31 GMT+01:00 Stephen Connolly <
> stephen.alan.connolly@gmail.com>:
> > Well here's a how do you do...
> >
> > If I compile BarMain.java with foo/Test2.java using a plain =42, I get:
> >
> > public class BarMain {
> >
> >   public BarMain();
> >
> >     Code:
> >
> >        0: aload_0
> >
> >        1: invokespecial #1                  // Method
> > java/lang/Object."<init>":()V
> >
> >        4: return
> >
> >
> >   public static void main(java.lang.String[]);
> >
> >     Code:
> >
> >        0: getstatic     #2                  // Field
> > java/lang/System.out:Ljava/io/PrintStream;
> >
> >        3: ldc           #4                  // String AZ 42
> >
> >        5: invokevirtual #5                  // Method
> > java/io/PrintStream.println:(Ljava/lang/String;)V
> >
> >        8: return
> >
> > }
> >
> >
> > If I compile BarMain.java with foo/Test2.java using the prevent inlining
> =
> > null!=null?0:42 I get:
> >
> > public class BarMain {
> >
> >   public BarMain();
> >
> >     Code:
> >
> >        0: aload_0
> >
> >        1: invokespecial #1                  // Method
> > java/lang/Object."<init>":()V
> >
> >        4: return
> >
> >
> >   public static void main(java.lang.String[]);
> >
> >     Code:
> >
> >        0: getstatic     #2                  // Field
> > java/lang/System.out:Ljava/io/PrintStream;
> >
> >        3: new           #3                  // class
> java/lang/StringBuilder
> >
> >        6: dup
> >
> >        7: invokespecial #4                  // Method
> > java/lang/StringBuilder."<init>":()V
> >
> >       10: ldc           #5                  // String AZ
> >
> >       12: invokevirtual #6                  // Method
> >
> java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
> >
> >       15: getstatic     #7                  // Field foo/Test2.AZAZ:I
> >
> >       18: invokevirtual #8                  // Method
> > java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
> >
> >       21: invokevirtual #9                  // Method
> > java/lang/StringBuilder.toString:()Ljava/lang/String;
> >
> >       24: invokevirtual #10                 // Method
> > java/io/PrintStream.println:(Ljava/lang/String;)V
> >
> >       27: return
> >
> > }
> >
> >
> > So what I see there is that in the first case javac has inlined the
> > constant and converted it to a string... in the second case it is
> > referencing the field directly
> >
> >
> >
> > On 25 November 2015 at 08:53, Kristian Rosenvold <
> > kristian.rosenvold@gmail.com> wrote:
> >
> >> Let me be more precise here; the dependency:analyze seems to miss a
> >> whole group of references to static fields. Both static imports and
> >> references to fields. In my code sample, I can do the following:
> >>
> >> javap -v bar/BarMain.class
> >>
> >> Classfile bar/BarMain.class
> >>   Last modified 25.nov.2015; size 583 bytes
> >>   MD5 checksum 02168be555cf779b31a4790f97b202a7
> >>   Compiled from "BarMain.java"
> >> public class bar.BarMain
> >>   minor version: 0
> >>   major version: 49
> >>   flags: ACC_PUBLIC, ACC_SUPER
> >> Constant pool:
> >>    #1 = Class              #23            // foo/Main
> >>    #2 = Methodref          #9.#24         //
> java/lang/Object."<init>":()V
> >>    #3 = Fieldref           #25.#26        //
> >> java/lang/System.out:Ljava/io/PrintStream;
> >>    #4 = String             #27            // SC compile
> >>    #5 = Methodref          #28.#29        //
> >> java/io/PrintStream.println:(Ljava/lang/String;)V
> >>    #6 = Class              #30            // foo/Test2
> >>    #7 = String             #31            // AZ 42
> >>    #8 = Class              #32            // bar/BarMain
> >>    #9 = Class              #33            // java/lang/Object
> >>   #10 = Utf8               <init>
> >>   #11 = Utf8               ()V
> >>   #12 = Utf8               Code
> >>   #13 = Utf8               LineNumberTable
> >>   #14 = Utf8               LocalVariableTable
> >>   #15 = Utf8               this
> >>   #16 = Utf8               Lbar/BarMain;
> >>   #17 = Utf8               main
> >>   #18 = Utf8               ([Ljava/lang/String;)V
> >>   #19 = Utf8               args
> >>   #20 = Utf8               [Ljava/lang/String;
> >>   #21 = Utf8               SourceFile
> >>   #22 = Utf8               BarMain.java
> >>   #23 = Utf8               foo/Main
> >>   #24 = NameAndType        #10:#11        // "<init>":()V
> >>   #25 = Class              #34            // java/lang/System
> >>   #26 = NameAndType        #35:#36        // out:Ljava/io/PrintStream;
> >>   #27 = Utf8               SC compile
> >>   #28 = Class              #37            // java/io/PrintStream
> >>   #29 = NameAndType        #38:#39        //
> println:(Ljava/lang/String;)V
> >>   #30 = Utf8               foo/Test2
> >>   #31 = Utf8               AZ 42
> >>   #32 = Utf8               bar/BarMain
> >>   #33 = Utf8               java/lang/Object
> >>   #34 = Utf8               java/lang/System
> >>   #35 = Utf8               out
> >>   #36 = Utf8               Ljava/io/PrintStream;
> >>   #37 = Utf8               java/io/PrintStream
> >>   #38 = Utf8               println
> >>   #39 = Utf8               (Ljava/lang/String;)V
> >> {
> >>   public bar.BarMain();
> >>     descriptor: ()V
> >>     flags: ACC_PUBLIC
> >>     Code:
> >>       stack=1, locals=1, args_size=1
> >>          0: aload_0
> >>          1: invokespecial #2                  // Method
> >> java/lang/Object."<init>":()V
> >>          4: return
> >>       LineNumberTable:
> >>         line 25: 0
> >>       LocalVariableTable:
> >>         Start  Length  Slot  Name   Signature
> >>             0       5     0  this   Lbar/BarMain;
> >>
> >>   public static void main(java.lang.String[]);
> >>     descriptor: ([Ljava/lang/String;)V
> >>     flags: ACC_PUBLIC, ACC_STATIC
> >>     Code:
> >>       stack=2, locals=1, args_size=1
> >>          0: getstatic     #3                  // Field
> >> java/lang/System.out:Ljava/io/PrintStream;
> >>          3: ldc           #4                  // String SC compile
> >>          5: invokevirtual #5                  // Method
> >> java/io/PrintStream.println:(Ljava/lang/String;)V
> >>          8: getstatic     #3                  // Field
> >> java/lang/System.out:Ljava/io/PrintStream;
> >>         11: ldc           #7                  // String AZ 42
> >>         13: invokevirtual #5                  // Method
> >> java/io/PrintStream.println:(Ljava/lang/String;)V
> >>         16: return
> >>       LineNumberTable:
> >>         line 28: 0
> >>         line 29: 8
> >>         line 30: 16
> >>       LocalVariableTable:
> >>         Start  Length  Slot  Name   Signature
> >>             0      17     0  args   [Ljava/lang/String;
> >> }
> >> SourceFile: "BarMain.java"
> >>
> >> As we can see the "import" class "foo/Test" is item #6/#30 and
> >> referenced in the constant pool for the BarMain class. The dependency
> >> analyzer does not seem to catch this. I'm a bit of a n00b in this
> >> regard, anyone have any tips on how to do this ?
> >>
> >> Kristian
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> >> For additional commands, e-mail: dev-help@maven.apache.org
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Kristian Rosenvold <kr...@gmail.com>.
What I still dont understand is;

the string might be inlined, but the "import" still seems to be
visible in the bytecode. Shouldn't dependency:analyze consider this a
"usage" ?

Kristian


2015-11-25 10:31 GMT+01:00 Stephen Connolly <st...@gmail.com>:
> Well here's a how do you do...
>
> If I compile BarMain.java with foo/Test2.java using a plain =42, I get:
>
> public class BarMain {
>
>   public BarMain();
>
>     Code:
>
>        0: aload_0
>
>        1: invokespecial #1                  // Method
> java/lang/Object."<init>":()V
>
>        4: return
>
>
>   public static void main(java.lang.String[]);
>
>     Code:
>
>        0: getstatic     #2                  // Field
> java/lang/System.out:Ljava/io/PrintStream;
>
>        3: ldc           #4                  // String AZ 42
>
>        5: invokevirtual #5                  // Method
> java/io/PrintStream.println:(Ljava/lang/String;)V
>
>        8: return
>
> }
>
>
> If I compile BarMain.java with foo/Test2.java using the prevent inlining =
> null!=null?0:42 I get:
>
> public class BarMain {
>
>   public BarMain();
>
>     Code:
>
>        0: aload_0
>
>        1: invokespecial #1                  // Method
> java/lang/Object."<init>":()V
>
>        4: return
>
>
>   public static void main(java.lang.String[]);
>
>     Code:
>
>        0: getstatic     #2                  // Field
> java/lang/System.out:Ljava/io/PrintStream;
>
>        3: new           #3                  // class java/lang/StringBuilder
>
>        6: dup
>
>        7: invokespecial #4                  // Method
> java/lang/StringBuilder."<init>":()V
>
>       10: ldc           #5                  // String AZ
>
>       12: invokevirtual #6                  // Method
> java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
>
>       15: getstatic     #7                  // Field foo/Test2.AZAZ:I
>
>       18: invokevirtual #8                  // Method
> java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
>
>       21: invokevirtual #9                  // Method
> java/lang/StringBuilder.toString:()Ljava/lang/String;
>
>       24: invokevirtual #10                 // Method
> java/io/PrintStream.println:(Ljava/lang/String;)V
>
>       27: return
>
> }
>
>
> So what I see there is that in the first case javac has inlined the
> constant and converted it to a string... in the second case it is
> referencing the field directly
>
>
>
> On 25 November 2015 at 08:53, Kristian Rosenvold <
> kristian.rosenvold@gmail.com> wrote:
>
>> Let me be more precise here; the dependency:analyze seems to miss a
>> whole group of references to static fields. Both static imports and
>> references to fields. In my code sample, I can do the following:
>>
>> javap -v bar/BarMain.class
>>
>> Classfile bar/BarMain.class
>>   Last modified 25.nov.2015; size 583 bytes
>>   MD5 checksum 02168be555cf779b31a4790f97b202a7
>>   Compiled from "BarMain.java"
>> public class bar.BarMain
>>   minor version: 0
>>   major version: 49
>>   flags: ACC_PUBLIC, ACC_SUPER
>> Constant pool:
>>    #1 = Class              #23            // foo/Main
>>    #2 = Methodref          #9.#24         // java/lang/Object."<init>":()V
>>    #3 = Fieldref           #25.#26        //
>> java/lang/System.out:Ljava/io/PrintStream;
>>    #4 = String             #27            // SC compile
>>    #5 = Methodref          #28.#29        //
>> java/io/PrintStream.println:(Ljava/lang/String;)V
>>    #6 = Class              #30            // foo/Test2
>>    #7 = String             #31            // AZ 42
>>    #8 = Class              #32            // bar/BarMain
>>    #9 = Class              #33            // java/lang/Object
>>   #10 = Utf8               <init>
>>   #11 = Utf8               ()V
>>   #12 = Utf8               Code
>>   #13 = Utf8               LineNumberTable
>>   #14 = Utf8               LocalVariableTable
>>   #15 = Utf8               this
>>   #16 = Utf8               Lbar/BarMain;
>>   #17 = Utf8               main
>>   #18 = Utf8               ([Ljava/lang/String;)V
>>   #19 = Utf8               args
>>   #20 = Utf8               [Ljava/lang/String;
>>   #21 = Utf8               SourceFile
>>   #22 = Utf8               BarMain.java
>>   #23 = Utf8               foo/Main
>>   #24 = NameAndType        #10:#11        // "<init>":()V
>>   #25 = Class              #34            // java/lang/System
>>   #26 = NameAndType        #35:#36        // out:Ljava/io/PrintStream;
>>   #27 = Utf8               SC compile
>>   #28 = Class              #37            // java/io/PrintStream
>>   #29 = NameAndType        #38:#39        // println:(Ljava/lang/String;)V
>>   #30 = Utf8               foo/Test2
>>   #31 = Utf8               AZ 42
>>   #32 = Utf8               bar/BarMain
>>   #33 = Utf8               java/lang/Object
>>   #34 = Utf8               java/lang/System
>>   #35 = Utf8               out
>>   #36 = Utf8               Ljava/io/PrintStream;
>>   #37 = Utf8               java/io/PrintStream
>>   #38 = Utf8               println
>>   #39 = Utf8               (Ljava/lang/String;)V
>> {
>>   public bar.BarMain();
>>     descriptor: ()V
>>     flags: ACC_PUBLIC
>>     Code:
>>       stack=1, locals=1, args_size=1
>>          0: aload_0
>>          1: invokespecial #2                  // Method
>> java/lang/Object."<init>":()V
>>          4: return
>>       LineNumberTable:
>>         line 25: 0
>>       LocalVariableTable:
>>         Start  Length  Slot  Name   Signature
>>             0       5     0  this   Lbar/BarMain;
>>
>>   public static void main(java.lang.String[]);
>>     descriptor: ([Ljava/lang/String;)V
>>     flags: ACC_PUBLIC, ACC_STATIC
>>     Code:
>>       stack=2, locals=1, args_size=1
>>          0: getstatic     #3                  // Field
>> java/lang/System.out:Ljava/io/PrintStream;
>>          3: ldc           #4                  // String SC compile
>>          5: invokevirtual #5                  // Method
>> java/io/PrintStream.println:(Ljava/lang/String;)V
>>          8: getstatic     #3                  // Field
>> java/lang/System.out:Ljava/io/PrintStream;
>>         11: ldc           #7                  // String AZ 42
>>         13: invokevirtual #5                  // Method
>> java/io/PrintStream.println:(Ljava/lang/String;)V
>>         16: return
>>       LineNumberTable:
>>         line 28: 0
>>         line 29: 8
>>         line 30: 16
>>       LocalVariableTable:
>>         Start  Length  Slot  Name   Signature
>>             0      17     0  args   [Ljava/lang/String;
>> }
>> SourceFile: "BarMain.java"
>>
>> As we can see the "import" class "foo/Test" is item #6/#30 and
>> referenced in the constant pool for the BarMain class. The dependency
>> analyzer does not seem to catch this. I'm a bit of a n00b in this
>> regard, anyone have any tips on how to do this ?
>>
>> Kristian
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Stephen Connolly <st...@gmail.com>.
Well here's a how do you do...

If I compile BarMain.java with foo/Test2.java using a plain =42, I get:

public class BarMain {

  public BarMain();

    Code:

       0: aload_0

       1: invokespecial #1                  // Method
java/lang/Object."<init>":()V

       4: return


  public static void main(java.lang.String[]);

    Code:

       0: getstatic     #2                  // Field
java/lang/System.out:Ljava/io/PrintStream;

       3: ldc           #4                  // String AZ 42

       5: invokevirtual #5                  // Method
java/io/PrintStream.println:(Ljava/lang/String;)V

       8: return

}


If I compile BarMain.java with foo/Test2.java using the prevent inlining =
null!=null?0:42 I get:

public class BarMain {

  public BarMain();

    Code:

       0: aload_0

       1: invokespecial #1                  // Method
java/lang/Object."<init>":()V

       4: return


  public static void main(java.lang.String[]);

    Code:

       0: getstatic     #2                  // Field
java/lang/System.out:Ljava/io/PrintStream;

       3: new           #3                  // class java/lang/StringBuilder

       6: dup

       7: invokespecial #4                  // Method
java/lang/StringBuilder."<init>":()V

      10: ldc           #5                  // String AZ

      12: invokevirtual #6                  // Method
java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;

      15: getstatic     #7                  // Field foo/Test2.AZAZ:I

      18: invokevirtual #8                  // Method
java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;

      21: invokevirtual #9                  // Method
java/lang/StringBuilder.toString:()Ljava/lang/String;

      24: invokevirtual #10                 // Method
java/io/PrintStream.println:(Ljava/lang/String;)V

      27: return

}


So what I see there is that in the first case javac has inlined the
constant and converted it to a string... in the second case it is
referencing the field directly



On 25 November 2015 at 08:53, Kristian Rosenvold <
kristian.rosenvold@gmail.com> wrote:

> Let me be more precise here; the dependency:analyze seems to miss a
> whole group of references to static fields. Both static imports and
> references to fields. In my code sample, I can do the following:
>
> javap -v bar/BarMain.class
>
> Classfile bar/BarMain.class
>   Last modified 25.nov.2015; size 583 bytes
>   MD5 checksum 02168be555cf779b31a4790f97b202a7
>   Compiled from "BarMain.java"
> public class bar.BarMain
>   minor version: 0
>   major version: 49
>   flags: ACC_PUBLIC, ACC_SUPER
> Constant pool:
>    #1 = Class              #23            // foo/Main
>    #2 = Methodref          #9.#24         // java/lang/Object."<init>":()V
>    #3 = Fieldref           #25.#26        //
> java/lang/System.out:Ljava/io/PrintStream;
>    #4 = String             #27            // SC compile
>    #5 = Methodref          #28.#29        //
> java/io/PrintStream.println:(Ljava/lang/String;)V
>    #6 = Class              #30            // foo/Test2
>    #7 = String             #31            // AZ 42
>    #8 = Class              #32            // bar/BarMain
>    #9 = Class              #33            // java/lang/Object
>   #10 = Utf8               <init>
>   #11 = Utf8               ()V
>   #12 = Utf8               Code
>   #13 = Utf8               LineNumberTable
>   #14 = Utf8               LocalVariableTable
>   #15 = Utf8               this
>   #16 = Utf8               Lbar/BarMain;
>   #17 = Utf8               main
>   #18 = Utf8               ([Ljava/lang/String;)V
>   #19 = Utf8               args
>   #20 = Utf8               [Ljava/lang/String;
>   #21 = Utf8               SourceFile
>   #22 = Utf8               BarMain.java
>   #23 = Utf8               foo/Main
>   #24 = NameAndType        #10:#11        // "<init>":()V
>   #25 = Class              #34            // java/lang/System
>   #26 = NameAndType        #35:#36        // out:Ljava/io/PrintStream;
>   #27 = Utf8               SC compile
>   #28 = Class              #37            // java/io/PrintStream
>   #29 = NameAndType        #38:#39        // println:(Ljava/lang/String;)V
>   #30 = Utf8               foo/Test2
>   #31 = Utf8               AZ 42
>   #32 = Utf8               bar/BarMain
>   #33 = Utf8               java/lang/Object
>   #34 = Utf8               java/lang/System
>   #35 = Utf8               out
>   #36 = Utf8               Ljava/io/PrintStream;
>   #37 = Utf8               java/io/PrintStream
>   #38 = Utf8               println
>   #39 = Utf8               (Ljava/lang/String;)V
> {
>   public bar.BarMain();
>     descriptor: ()V
>     flags: ACC_PUBLIC
>     Code:
>       stack=1, locals=1, args_size=1
>          0: aload_0
>          1: invokespecial #2                  // Method
> java/lang/Object."<init>":()V
>          4: return
>       LineNumberTable:
>         line 25: 0
>       LocalVariableTable:
>         Start  Length  Slot  Name   Signature
>             0       5     0  this   Lbar/BarMain;
>
>   public static void main(java.lang.String[]);
>     descriptor: ([Ljava/lang/String;)V
>     flags: ACC_PUBLIC, ACC_STATIC
>     Code:
>       stack=2, locals=1, args_size=1
>          0: getstatic     #3                  // Field
> java/lang/System.out:Ljava/io/PrintStream;
>          3: ldc           #4                  // String SC compile
>          5: invokevirtual #5                  // Method
> java/io/PrintStream.println:(Ljava/lang/String;)V
>          8: getstatic     #3                  // Field
> java/lang/System.out:Ljava/io/PrintStream;
>         11: ldc           #7                  // String AZ 42
>         13: invokevirtual #5                  // Method
> java/io/PrintStream.println:(Ljava/lang/String;)V
>         16: return
>       LineNumberTable:
>         line 28: 0
>         line 29: 8
>         line 30: 16
>       LocalVariableTable:
>         Start  Length  Slot  Name   Signature
>             0      17     0  args   [Ljava/lang/String;
> }
> SourceFile: "BarMain.java"
>
> As we can see the "import" class "foo/Test" is item #6/#30 and
> referenced in the constant pool for the BarMain class. The dependency
> analyzer does not seem to catch this. I'm a bit of a n00b in this
> regard, anyone have any tips on how to do this ?
>
> Kristian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Kristian Rosenvold <kr...@gmail.com>.
Let me be more precise here; the dependency:analyze seems to miss a
whole group of references to static fields. Both static imports and
references to fields. In my code sample, I can do the following:

javap -v bar/BarMain.class

Classfile bar/BarMain.class
  Last modified 25.nov.2015; size 583 bytes
  MD5 checksum 02168be555cf779b31a4790f97b202a7
  Compiled from "BarMain.java"
public class bar.BarMain
  minor version: 0
  major version: 49
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
   #1 = Class              #23            // foo/Main
   #2 = Methodref          #9.#24         // java/lang/Object."<init>":()V
   #3 = Fieldref           #25.#26        //
java/lang/System.out:Ljava/io/PrintStream;
   #4 = String             #27            // SC compile
   #5 = Methodref          #28.#29        //
java/io/PrintStream.println:(Ljava/lang/String;)V
   #6 = Class              #30            // foo/Test2
   #7 = String             #31            // AZ 42
   #8 = Class              #32            // bar/BarMain
   #9 = Class              #33            // java/lang/Object
  #10 = Utf8               <init>
  #11 = Utf8               ()V
  #12 = Utf8               Code
  #13 = Utf8               LineNumberTable
  #14 = Utf8               LocalVariableTable
  #15 = Utf8               this
  #16 = Utf8               Lbar/BarMain;
  #17 = Utf8               main
  #18 = Utf8               ([Ljava/lang/String;)V
  #19 = Utf8               args
  #20 = Utf8               [Ljava/lang/String;
  #21 = Utf8               SourceFile
  #22 = Utf8               BarMain.java
  #23 = Utf8               foo/Main
  #24 = NameAndType        #10:#11        // "<init>":()V
  #25 = Class              #34            // java/lang/System
  #26 = NameAndType        #35:#36        // out:Ljava/io/PrintStream;
  #27 = Utf8               SC compile
  #28 = Class              #37            // java/io/PrintStream
  #29 = NameAndType        #38:#39        // println:(Ljava/lang/String;)V
  #30 = Utf8               foo/Test2
  #31 = Utf8               AZ 42
  #32 = Utf8               bar/BarMain
  #33 = Utf8               java/lang/Object
  #34 = Utf8               java/lang/System
  #35 = Utf8               out
  #36 = Utf8               Ljava/io/PrintStream;
  #37 = Utf8               java/io/PrintStream
  #38 = Utf8               println
  #39 = Utf8               (Ljava/lang/String;)V
{
  public bar.BarMain();
    descriptor: ()V
    flags: ACC_PUBLIC
    Code:
      stack=1, locals=1, args_size=1
         0: aload_0
         1: invokespecial #2                  // Method
java/lang/Object."<init>":()V
         4: return
      LineNumberTable:
        line 25: 0
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0       5     0  this   Lbar/BarMain;

  public static void main(java.lang.String[]);
    descriptor: ([Ljava/lang/String;)V
    flags: ACC_PUBLIC, ACC_STATIC
    Code:
      stack=2, locals=1, args_size=1
         0: getstatic     #3                  // Field
java/lang/System.out:Ljava/io/PrintStream;
         3: ldc           #4                  // String SC compile
         5: invokevirtual #5                  // Method
java/io/PrintStream.println:(Ljava/lang/String;)V
         8: getstatic     #3                  // Field
java/lang/System.out:Ljava/io/PrintStream;
        11: ldc           #7                  // String AZ 42
        13: invokevirtual #5                  // Method
java/io/PrintStream.println:(Ljava/lang/String;)V
        16: return
      LineNumberTable:
        line 28: 0
        line 29: 8
        line 30: 16
      LocalVariableTable:
        Start  Length  Slot  Name   Signature
            0      17     0  args   [Ljava/lang/String;
}
SourceFile: "BarMain.java"

As we can see the "import" class "foo/Test" is item #6/#30 and
referenced in the constant pool for the BarMain class. The dependency
analyzer does not seem to catch this. I'm a bit of a n00b in this
regard, anyone have any tips on how to do this ?

Kristian

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Tibor Digana <ti...@apache.org>.
AFAIK javac must keeps calling static field Test2.AZAZ.
But the runtime compiler (JustInTime compiler JIT) may or may not compile
the field to constant and inline private methods. That's the reason why
Java Reflection won't see any changes on the field if you call
setAccessible(true) and rewrite the field earlier before the reads.

On Wed, Nov 25, 2015 at 8:26 AM, Andreas Gudian [via Maven] <
ml-node+s40175n5852870h10@n5.nabble.com> wrote:

> AFAIR, such constants (primitives and Strings) are inlined by the compiler
> - and the dependeny analyzer works on the bytecode and not the sources,
> right?
>
>
>
> Am Mittwoch, 25. November 2015 schrieb Jochen Wiedmann :
>
> > What exactly is it, you'd like to detect?
> >
> >
> > On Wed, Nov 25, 2015 at 8:11 AM, Kristian Rosenvold
> > <[hidden email] <http:///user/SendEmail.jtp?type=node&node=5852870&i=0>
> <javascript:;>> wrote:
> > > I poked around in the depdenedncy analyzer code to see if I could make
> > > it "see" the following code:
> > >
> > > Module 1:
> > > public class Test2 {
> > >     public static final int AZAZ = 42;
> > > }
> > >
> > > Module 2:
> > >
> > > import foo.Test2;
> > >
> > > public class BarMain
> > > {
> > >     public static void main(String[] args) {
> > >         System.out.println("AZ " + Test2.AZAZ);
> > >     }
> > > }
> > >
> > > Isn't this possible to detect or am I just a total n00b with asm ??
> > >
> > >
> > > Kristian
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5852870&i=1> <javascript:;>
> > > For additional commands, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5852870&i=2>
> > <javascript:;>
> > >
> >
> >
> >
> > --
> > The next time you hear: "Don't reinvent the wheel!"
> >
> >
> >
> http://www.keystonedevelopment.co.uk/wp-content/uploads/2014/10/evolution-of-the-wheel-300x85.jpg
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5852870&i=3> <javascript:;>
> > For additional commands, e-mail: [hidden email]
> <http:///user/SendEmail.jtp?type=node&node=5852870&i=4> <javascript:;>
> >
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://maven.40175.n5.nabble.com/Why-can-t-dependency-plugin-see-statics-and-staticimports-tp5852860p5852870.html
> To start a new topic under Maven Developers, email
> ml-node+s40175n142166h86@n5.nabble.com
> To unsubscribe from Maven Developers, click here
> <http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=142166&code=dGlib3JkaWdhbmFAYXBhY2hlLm9yZ3wxNDIxNjZ8LTI4OTQ5MjEwMg==>
> .
> NAML
> <http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://maven.40175.n5.nabble.com/Why-can-t-dependency-plugin-see-statics-and-staticimports-tp5852860p5852872.html
Sent from the Maven Developers mailing list archive at Nabble.com.

Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Andreas Gudian <an...@gmail.com>.
AFAIR, such constants (primitives and Strings) are inlined by the compiler
- and the dependeny analyzer works on the bytecode and not the sources,
right?



Am Mittwoch, 25. November 2015 schrieb Jochen Wiedmann :

> What exactly is it, you'd like to detect?
>
>
> On Wed, Nov 25, 2015 at 8:11 AM, Kristian Rosenvold
> <kristian.rosenvold@gmail.com <javascript:;>> wrote:
> > I poked around in the depdenedncy analyzer code to see if I could make
> > it "see" the following code:
> >
> > Module 1:
> > public class Test2 {
> >     public static final int AZAZ = 42;
> > }
> >
> > Module 2:
> >
> > import foo.Test2;
> >
> > public class BarMain
> > {
> >     public static void main(String[] args) {
> >         System.out.println("AZ " + Test2.AZAZ);
> >     }
> > }
> >
> > Isn't this possible to detect or am I just a total n00b with asm ??
> >
> >
> > Kristian
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org <javascript:;>
> > For additional commands, e-mail: dev-help@maven.apache.org
> <javascript:;>
> >
>
>
>
> --
> The next time you hear: "Don't reinvent the wheel!"
>
>
> http://www.keystonedevelopment.co.uk/wp-content/uploads/2014/10/evolution-of-the-wheel-300x85.jpg
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: dev-help@maven.apache.org <javascript:;>
>
>

Re: Why can't dependency plugin "see" statics /and staticimports

Posted by Jochen Wiedmann <jo...@gmail.com>.
What exactly is it, you'd like to detect?


On Wed, Nov 25, 2015 at 8:11 AM, Kristian Rosenvold
<kr...@gmail.com> wrote:
> I poked around in the depdenedncy analyzer code to see if I could make
> it "see" the following code:
>
> Module 1:
> public class Test2 {
>     public static final int AZAZ = 42;
> }
>
> Module 2:
>
> import foo.Test2;
>
> public class BarMain
> {
>     public static void main(String[] args) {
>         System.out.println("AZ " + Test2.AZAZ);
>     }
> }
>
> Isn't this possible to detect or am I just a total n00b with asm ??
>
>
> Kristian
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>



-- 
The next time you hear: "Don't reinvent the wheel!"

http://www.keystonedevelopment.co.uk/wp-content/uploads/2014/10/evolution-of-the-wheel-300x85.jpg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org