1
Vote

java.lang.VerifyError for SHORTCHAR type

description

This code successfully compiled, but at runtime there is jvm Verify Error:
MODULE Test;
    IMPORT CPmain;

    PROCEDURE Test1 (a : SHORTCHAR); BEGIN END Test1;
    
    PROCEDURE Do*;
    VAR
        a  : SHORTCHAR;
    BEGIN       
        a := "a"; 
        Test1(a);
    END Do; 
BEGIN
    Do;
END Test.
Runtime error:
Exception in thread "main" java.lang.VerifyError: (class: CP/Test/Test, method: Do signature: ()V) Expecting to find integer on stack
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
.NET version works well.

comments

k_john_gough wrote May 26, 2013 at 11:26 AM

Hi valexey. I have checked your example, and yes, it does cause a verify error. It works perfectly well for all the SHORTCHAR variables retyped as CHAR.

The problem is in the handling of the literal "a" which is wrongly being treated as a string in the conversion to the SHORTCHAR. I expect this to be able to be fixed very quickly, and will refresh the distribution.

John

valexey wrote May 26, 2013 at 12:14 PM

I think that there is more general problem with SHORTCHAR type for JVM gpcp version.

Next example also generates VerifyError at run time:
MODULE Test;
    IMPORT CPmain;

    TYPE ShortCharArray = ARRAY 10 OF SHORTCHAR;

    PROCEDURE Test1 (a : ShortCharArray); BEGIN END Test1;
    
    PROCEDURE Do*;
    VAR
        a  : ShortCharArray;
    BEGIN       
        Test1(a);
    END Do; 
BEGIN
    Do;
END Test.
Error:
Exception in thread "main" java.lang.VerifyError: (class: CP/Test/Test, method: Do signature: ()V) Expecting to find array of chars on stack
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.getMainMethod(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

k_john_gough wrote Jun 4, 2013 at 4:28 AM

The source has been fixed for both of the SHORTCHAR dependent errors mentioned by valexey.
There were two separate code errors here. An incorrect mapping from GPCP's ordinal for built-in types and the enumeration used by the JVM; The other error was the incorrect implicit conversion for literal strings of length equal to one converted to SHORTCHAR that I mentioned in my previous post.

The fixes have been committed to the repository, in revision 29756. Unless anyone turns up any new SHORTCHAR related problems in the next few days I will generate and release version 1.3.17.

John