Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jdt-dev] How does this code work ?
  • From: "Sankaran, Srikanth" <srikanth.sankaran@xxxxxxxxxxxxx>
  • Date: Wed, 22 May 2024 07:14:58 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=advantest.com; dmarc=pass action=none header.from=advantest.com; dkim=pass header.d=advantest.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XXgPaFtSpE3nwT55OT2LsdhGcZ/VhtndBS82QNyDZGs=; b=fKGRSEEVUkKjS7u1d6BZE8xCSz7BUPKX8G+YeBwXn69rEvpts69v1NjQYm5H9k6moboh6QAeA/jrylz9X4skNVw6OxC1dctxRIP0jWaIHZOQQH2/H+ySJBpLITbzrhkbuU+f9Zd/0dhAaoP9bR28PHKjN1PX4p3czd5lelQdWStXIza087H5YuD9sxgpOqoD8h2EnDNov4YpbI6aftFUIIaPR8WpmOGMJLC239xjaaQsJeReVVOFzcPrtguI3tCQxOkyaqw5W/Up/vOPucrh+qGHSL/PmKTEOOZBc9EVDCzU1xxITf03m/wBlIOoVHUO+eBDZO2dUIiqmiUr9QB8KQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FQUPhED6dFwaY1nlxhtNgpyMhztRMnRD6NAXazxniI555T4AOqerZFUa0bzZkWnR0pJxad9tsskFyGqf42+18ys5UQKTsAm6MMTBsALrBAD5ruL6RP0Ti+5pjtanzpYqx35N8MX0J2CD/eBSV5ejH7y6RpY70Mb9YeEr9jlPNF9R17zJIxdHRIJPdhl7tO941A+Ub0ykzjbN1w8gz+Mz8o4sVhsflA9shnTT8PQpksCHgUCS8L/Zc4XvK3RECWf2yrTLDYWIJX94DBsjDre6xO4a2fCsqZtftP1VAvF7M3RzH004Ui4bOErV2EJVVB0Bb+2j6Zu+hiGd7yw4XgnSHg==
  • Delivered-to: jdt-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/jdt-dev/>
  • List-help: <mailto:jdt-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/jdt-dev>, <mailto:jdt-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/jdt-dev>, <mailto:jdt-dev-request@eclipse.org?subject=unsubscribe>
  • Thread-index: AdqsDSnBdjzOBB2kRnK1ENZTitA2qgABb/6AAAEn7fA=
  • Thread-topic: [jdt-dev] How does this code work ?

While that mystery is solved, the remaining puzzle is how we ended up with two nearly identical versions of the method generateClassLiteralAccessForType in CodeStream and StackMapFrameCodeStream.

 

Srikanth

 

From: jdt-dev <jdt-dev-bounces@xxxxxxxxxxx> On Behalf Of Sankaran, Srikanth via jdt-dev
Sent: Wednesday, May 22, 2024 12:12 PM
To: Eclipse JDT general developers list. <jdt-dev@xxxxxxxxxxx>
Cc: Sankaran, Srikanth <srikanth.sankaran@xxxxxxxxxxxxx>
Subject: Re: [jdt-dev] How does this code work ?

 

CAUTION: This email was sent from outside of Advantest.

 

It seems you need a branch and so a different stackmap frame for verification to catch such problems.

 

I have raised https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2476 with a test case where we do get a verify error.

 

Thanks

Srikanth

 

From: jdt-dev <jdt-dev-bounces@xxxxxxxxxxx> On Behalf Of Sankaran, Srikanth via jdt-dev
Sent: Wednesday, May 22, 2024 11:33 AM
To: jdt-dev@xxxxxxxxxxx
Cc: Sankaran, Srikanth <srikanth.sankaran@xxxxxxxxxxxxx>
Subject: [jdt-dev] How does this code work ?

 

CAUTION: This email was sent from outside of Advantest.

 

I have been staring at this code for a while now wondering how the bad code generated still works:

 

public class X {

       public static void main(String[] args) {

             

              foo(String.class, switch (42) {

              default -> {

                     try {

                           yield 42;

                     } finally {

 

                     }

              }

              });

       }

      

       static void foo(Class<?> c, int v) {

              System.out.println(c);

              System.out.println(v);

       }

}

 

 

On master, we generate the following code:

 

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

    descriptor: ([Ljava/lang/String;)V

    flags: (0x0009) ACC_PUBLIC, ACC_STATIC

    Code:

      stack=2, locals=3, args_size=1

         0: ldc           #16                 // class java/lang/String

         2: astore_1                        <<ß-------------------- Class Object being stored into String See LVT slot 1 below.

         3: bipush        42

         5: istore_2

         6: aload_1                             <<ß-------------------- aload loads an object statically typed String, but at bci 8 we invoke a method that expects a Class object

         7: iload_2

         8: invokestatic  #18                 // Method foo:(Ljava/lang/Class;I)V

        11: return

      LineNumberTable:

        line 4: 0

        line 7: 3

        line 4: 8

        line 13: 11

      LocalVariableTable:

        Start  Length  Slot  Name   Signature

            0      12     0  args   [Ljava/lang/String;

            3       5     1  yieldValue0   Ljava/lang/String;  <<ß---------------------- String typed local

            6       2     2  secretYieldValue   I

 

What am I overlooking ??

 

Srikanth


Back to the top