[jboss-jira] [JBoss JIRA] (JASSIST-262) Class compilation error - Inconsistent stackmap

Shigeru Chiba (JIRA) issues at jboss.org
Wed Apr 27 10:10:00 EDT 2016


     [ https://issues.jboss.org/browse/JASSIST-262?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Shigeru Chiba resolved JASSIST-262.
-----------------------------------
    Fix Version/s: 3.21.0-GA
       Resolution: Done


> Class compilation error - Inconsistent stackmap
> -----------------------------------------------
>
>                 Key: JASSIST-262
>                 URL: https://issues.jboss.org/browse/JASSIST-262
>             Project: Javassist
>          Issue Type: Bug
>    Affects Versions: 3.20.0-GA
>         Environment: org.javassist:javassist:3.20.0-GA
> java version "1.8.0_74"
> Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
> Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
> Linux 3.13.0-37-generic #64-Ubuntu SMP x86_64 GNU/Linux
>            Reporter: Alexey Kuznetsov
>            Assignee: Shigeru Chiba
>             Fix For: 3.21.0-GA
>
>
> {code:java}
> package com.company;
> import javassist.ClassPool;
> import javassist.CtClass;
> import javassist.CtMethod;
> public class Main {
>     public static void main(String[] args) {
>         CtClass badClass = ClassPool.getDefault().makeClass("badClass");
>         String src = String.join(System.getProperty("line.separator"),
>                 "public void eval () {",
>                 "    if (true) {",
>                 "        double t=0;",
>                 "    } else {",
>                 "        double t=0;",
>                 "    }",
>                 "    for (int i=0; i < 2; i++) {",
>                 "        int a=0;",
>                 "        int b=0;",
>                 "        int c=0;",
>                 "        int d=0;",
>                 "        if (true) {",
>                 "            int e = 0;",
>                 "        }",
>                 "    }",
>                 "}");
>         System.out.println(src);
>         try {
>             badClass.addMethod(CtMethod.make(src, badClass));
>             Class clazzz = badClass.toClass();
>             Object obj = clazzz.newInstance(); // <-- falls here
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }
> {code}
> After running that i get output:
> {noformat}
> public void eval () {
>     if (true) {
>         double t=0;
>     } else {
>         double t=0;
>     }
>     for (int i=0; i < 2; i++) {
>         int a=0;
>         int b=0;
>         int c=0;
>         int d=0;
>         if (true) {
>             int e = 0;
>         }
>     }
> }
> Exception in thread "main" java.lang.VerifyError: Inconsistent stackmap frames at branch target 41
> Exception Details:
>   Location:
>     badClass.eval()V @41: iinc
>   Reason:
>     Type top (current frame, locals[4]) is not assignable to integer (stack map, locals[4])
>   Current Frame:
>     bci: @35
>     flags: { }
>     locals: { 'badClass', top, top, top, top, integer, integer, integer, integer, integer }
>     stack: { integer }
>   Stackmap Frame:
>     bci: @41
>     flags: { }
>     locals: { 'badClass', top, top, top, integer, integer, integer, integer, integer }
>     stack: { }
>   Bytecode:
>     0x0000000: 0499 0009 0387 48a7 0006 0387 4a03 3605
>     0x0000010: 1505 05a2 001c 0336 0603 3607 0336 0803
>     0x0000020: 3609 0499 0006 0336 0a84 0501 a7ff e4b1
>     0x0000030:                                        
>   Stackmap Table:
>     same_frame(@10)
>     same_frame(@13)
>     full_frame(@16,{Object[#2],Top,Top,Top,Top,Integer},{})
>     full_frame(@41,{Object[#2],Top,Top,Top,Integer,Integer,Integer,Integer,Integer},{})
>     full_frame(@47,{Object[#2],Top,Top,Top,Top,Integer},{})
> 	at java.lang.Class.getDeclaredConstructors0(Native Method)
> 	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
> 	at java.lang.Class.getConstructor0(Class.java:3075)
> 	at java.lang.Class.newInstance(Class.java:412)
> 	at com.company.Main.main(Main.java:31)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
> Process finished with exit code 1
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list