RFR 7901507: JASM error when parsing invokedynamic static string argument

Kevin Looney kevin.looney at oracle.com
Wed Feb 15 17:21:40 UTC 2017


Hi Bernard,

Thanks for identifying this error, and providing a patch.   We will 
verify this soon, and update the repo.

Regards,
Kevin L

On 2/15/17 9:15 AM, B. Blaser wrote:
> Hi,
>
> Please review the patch below to correct jasm parsing error for
> invokedynamic static string argument.
>
> Jasm fails to assemble to following instruction:
>
>      invokedynamic REF_invokeStatic:bootstrap:"()V":target:"()V" int 0, "test";
>
> because the type tag isn't cleared after 'int 0' and not explicitly
> given for "test".
> Jasm keeps 'int' as tag for the "test" string argument and then fails...
>
> I also fully rewrote the static argument parsing loop due to a suspect
> handling of commas.
>
> Thanks,
> Bernard
>
> diff --git a/src/org/openjdk/asmtools/jasm/ParserCP.java
> b/src/org/openjdk/asmtools/jasm/ParserCP.java
> --- a/src/org/openjdk/asmtools/jasm/ParserCP.java
> +++ b/src/org/openjdk/asmtools/jasm/ParserCP.java
> @@ -1,5 +1,5 @@
>   /*
> - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
>    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
>    *
>    * This code is free software; you can redistribute it and/or modify it
> @@ -450,11 +450,11 @@
>                       ConstantPool.ConstCell NapeCell =
> parser.pool.FindCell(parseConstValue(ConstType.CONSTANT_NAMEANDTYPE));
>
>                       ArrayList<ConstantPool.ConstCell> bsm_args = new
> ArrayList<>(256);
> -                    while (scanner.token != Token.SEMICOLON) {
> -                        if (scanner.token == Token.COMMA) {
> -                            scanner.scan();
> -                        }
> +                    for (boolean sep=false; scanner.token !=
> Token.SEMICOLON; sep=true) {
> +                        if (sep) scanner.expect(Token.COMMA);
> +
>                           bsm_args.add(parseConstRef(null));
> +                        scanner.idValue = null; // Clear tag
>                       }
>                       BootstrapMethodData bsmData = new
> BootstrapMethodData(MHCell, bsm_args);
>                       parser.cd.addBootstrapMethod(bsmData);


-- 
kevin.looney at oracle.com



More information about the asmtools-dev mailing list