Forum Stats

  • 3,826,348 Users
  • 2,260,631 Discussions
  • 7,896,912 Comments

Discussions

Normalizer app - asm library, it can’t support jsr and ret byte code

d03a53f3-4e65-4f27-9ca0-e9b5a711bfbf
edited Aug 30, 2016 7:07AM in Java Card

Dear Community,

our question is regarding Normalizer app which is used by jdk 3.x of javacard.  And the issue is in the asm library used by the Normalizer.

We are using a financial applet and this has one try {} catch {} finally {} in the source code. After been compiled by javac from JDK1.4, the finally {} block is converted into byte code segments using jsr


L25:        jsr
L31;
L26:        goto L35;
L27:        astore 10;
             
sconst_m1;
               sstore 5;
               jsr L31;
L28:  
     goto L35;
L29:        astore 11;
               jsr L31;
L30:  
     aload 11;
               athrow;
L31:        astore 12;

The byte code jsr is compatible with java virtual machine, can be converted to cap file and loaded onto out card for execution, no compatibility issue.

But  when we run the Normalizer to convert the cap file back to class files, the Normalizer uses 3rd party ASM lib to do instrument.


set
JC_CLASSPATH=%JC_CLASSIC_HOME%\lib\api_classic_annotations.jar;%JC_CLASSPATH%

set JC_CLASSPATH=%JC_CLASSIC_HOME%\lib\asm-all-3.1.jar;%JC_CLASSPATH%

set JC_CLASSPATH=%JC_CLASSIC_HOME%\lib\bcel-5.2.jar;%JC_CLASSPATH%

we added  the -verbose:class parameter to the normalizer java VM execution, I got the log  which shows the RuntimeException is thrown by ASM


[Loaded
com.sun.javacard.components.caputils.CodeAttribute$ExceptionInfo from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/tools.jar]

[Loaded org.objectweb.asm.FieldWriter from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/asm-all-3.1.jar]

[Loaded org.objectweb.asm.Edge from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/asm-all-3.1.jar]

[Loaded org.objectweb.asm.Type from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/asm-all-3.1.jar]

[Loaded org.objectweb.asm.Handler from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/asm-all-3.1.jar]

java.lang.RuntimeException: JSR/RET are not supported with computeFrames
option
[Loaded com.sun.javacard.converter.ConverterHarness from file:/C:/Users/cchen4/Documents/DevZone/Libs/jc304/lib/tools.jar]

 

There is a known issue/limitation in the asm library, it can’t support jsr and ret byte code

src / org / objectweb
/ asm / Frame.java
       case Opcodes.JSR:
       case Opcodes.RET:

           throw new RuntimeException(
                   "JSR/RET are
not supported with computeFrames
option");


From ASM 4.0 and above, ASM provided JSRInlinerAdapter Class to transform jsr before processing to bypass this issue, but unfortunately Normalizer still uses old asm 3.1 library.

We have tried to switching to a high version of ASM lib (4.0 and 4.1) in normalizer and use the JSRInlinerAdapter but it is still failling.  Replacing the ASM lib doesn’t solve the problem.

Someone with the same issue? Do you know a different App to use than Normalizer?

We appreciate your support in this.

Regards,

Alvaro M.

Alvaro M-.

This discussion has been closed.