Github user mgaido91 commented on the issue:

    https://github.com/apache/spark/pull/19518
  
    @kiszk I meant that `janinoc` creates a slightly different constant pool 
from `javac`. I am not sure about performances, but the number of constant pool 
entries is definitely different. For instance, let's take this example and 
analyze the `Outer` class constant pool:
    ```
    class Outer {
      private Inner innerInstance = new Inner();
      private void outerMethod(){
        innerInstance.b = 1;
        innerInstance.a = 1;
      }
      private boolean outerMethod2(){
        return innerInstance.b > innerInstance.a;
      }
      private class Inner {
        int b =2;
        private int a = 0;
      }
    }
    ```
    if you compile it with `javac`, the constant pool will be:
    ```
    Constant pool:
       #1 = Methodref          #9.#25         // java/lang/Object."<init>":()V
       #2 = Class              #26            // Outer$Inner
       #3 = Methodref          #2.#27         // 
Outer$Inner."<init>":(LOuter;LOuter$1;)V
       #4 = Fieldref           #8.#28         // 
Outer.innerInstance:LOuter$Inner;
       #5 = Fieldref           #2.#29         // Outer$Inner.b:I
       #6 = Methodref          #2.#30         // 
Outer$Inner.access$102:(LOuter$Inner;I)I
       #7 = Methodref          #2.#31         // 
Outer$Inner.access$100:(LOuter$Inner;)I
       #8 = Class              #32            // Outer
       #9 = Class              #33            // java/lang/Object
      #10 = Class              #34            // Outer$1
      #11 = Utf8               InnerClasses
      #12 = Utf8               Inner
      #13 = Utf8               innerInstance
      #14 = Utf8               LOuter$Inner;
      #15 = Utf8               <init>
      #16 = Utf8               ()V
      #17 = Utf8               Code
      #18 = Utf8               LineNumberTable
      #19 = Utf8               outerMethod
      #20 = Utf8               outerMethod2
      #21 = Utf8               ()Z
      #22 = Utf8               StackMapTable
      #23 = Utf8               SourceFile
      #24 = Utf8               Outer.java
      #25 = NameAndType        #15:#16        // "<init>":()V
      #26 = Utf8               Outer$Inner
      #27 = NameAndType        #15:#35        // "<init>":(LOuter;LOuter$1;)V
      #28 = NameAndType        #13:#14        // innerInstance:LOuter$Inner;
      #29 = NameAndType        #36:#37        // b:I
      #30 = NameAndType        #38:#39        // access$102:(LOuter$Inner;I)I
      #31 = NameAndType        #40:#41        // access$100:(LOuter$Inner;)I
      #32 = Utf8               Outer
      #33 = Utf8               java/lang/Object
      #34 = Utf8               Outer$1
      #35 = Utf8               (LOuter;LOuter$1;)V
      #36 = Utf8               b
      #37 = Utf8               I
      #38 = Utf8               access$102
      #39 = Utf8               (LOuter$Inner;I)I
      #40 = Utf8               access$100
      #41 = Utf8               (LOuter$Inner;)I
    ```
    (please note that it creates a fake getter and a fake setter method entries 
for the `private` inner variable `a`). 
    
    If you compile the same class with `janinoc`, instead, the constant pool 
will be:
    ```
    Constant pool:
       #1 = Utf8               Outer
       #2 = Class              #1             // Outer
       #3 = Utf8               java/lang/Object
       #4 = Class              #3             // java/lang/Object
       #5 = Utf8               SourceFile
       #6 = Utf8               Outer.java
       #7 = Utf8               outerMethod$
       #8 = Utf8               (LOuter;)V
       #9 = Utf8               innerInstance
      #10 = Utf8               LOuter$Inner;
      #11 = NameAndType        #9:#10         // innerInstance:LOuter$Inner;
      #12 = Fieldref           #2.#11         // 
Outer.innerInstance:LOuter$Inner;
      #13 = Utf8               Outer$Inner
      #14 = Class              #13            // Outer$Inner
      #15 = Utf8               b
      #16 = Utf8               I
      #17 = NameAndType        #15:#16        // b:I
      #18 = Fieldref           #14.#17        // Outer$Inner.b:I
      #19 = Utf8               a
      #20 = NameAndType        #19:#16        // a:I
      #21 = Fieldref           #14.#20        // Outer$Inner.a:I
      #22 = Utf8               LineNumberTable
      #23 = Utf8               Code
      #24 = Utf8               outerMethod2$
      #25 = Utf8               (LOuter;)Z
      #26 = Utf8               <init>
      #27 = Utf8               ()V
      #28 = NameAndType        #26:#27        // "<init>":()V
      #29 = Methodref          #4.#28         // java/lang/Object."<init>":()V
      #30 = NameAndType        #26:#8         // "<init>":(LOuter;)V
      #31 = Methodref          #14.#30        // Outer$Inner."<init>":(LOuter;)V
      #32 = Utf8               Inner
      #33 = Utf8               InnerClasses
    ```
    (note that `a` now is considered as a regular field).
    
    Thus in all our tests we should use `janinoc` instead of `javac` to 
evaluate the behavior of the constant pool in the different cases.
    
    Let me know if you have any question or doubt. Thanks.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to