[PATCH][asmtools] Fix incorrect handling of quoted class names by jasm
Kevin Looney
kevin.looney at oracle.com
Tue Mar 6 16:35:43 UTC 2018
Hi Maxim,
Hmm - our mailer supports attachments. Another mystery .....
OK - this inline diff will work fine. Our AsmTools moderator will
evaluate your patch.
Thanks again for the contribution!
Regards,
Kevin L
On 3/6/18 8:26 AM, Maxim Degtyarev wrote:
> It seems file attach lost somewhere in the middle. Does this mailing
> list support attaches?
> Here is the patch:
>
> =====
>
> # HG changeset patch
> # User maccimo
> # Date 1520137328 -10800
> # Sun Mar 04 07:22:08 2018 +0300
> # Node ID 2704790eab9c060bc0ba3f3c29a31e95379224f4
> # Parent 872f704a0d9a0198ae7ce1ae12a676cb180fd424
> Fix quoted class names handling bug.
> Quoted class names was not prepended by proper package name even if
> *.jasm file contains "package" statement.
>
> diff --git a/src/org/openjdk/asmtools/jasm/Parser.java
> b/src/org/openjdk/asmtools/jasm/Parser.java
> --- a/src/org/openjdk/asmtools/jasm/Parser.java
> +++ b/src/org/openjdk/asmtools/jasm/Parser.java
> @@ -416,6 +416,7 @@
> case STRINGVAL:
> v = scanner.stringValue;
> scanner.scan();
> + v = prependPackage(v, uncond);
> return pool.FindCellAsciz(v);
> // Some identifiers might coincide with token names.
> // these should be OK to use as identifier names.
> @@ -435,12 +436,7 @@
> case IDENT:
> v = scanner.idValue;
> scanner.scan();
> - if (uncond || (scanner.token == Token.FIELD)) {
> - if ((!v.contains("/")) // class
> identifier doesn't contain "/"
> - && (!v.contains("["))){ // class
> identifier doesn't contain "["
> - v = pkgPrefix + v; // add package
> - }
> - }
> + v = prependPackage(v, uncond);
> return pool.FindCellAsciz(v);
> default:
> ConstType key = Tables.tag(scanner.token.value());
> @@ -450,6 +446,16 @@
> }
> }
>
> + private String prependPackage(String className, boolean uncond) {
> + if (uncond || (scanner.token == Token.FIELD)) {
> + if ((!className.contains("/")) // class
> identifier doesn't contain "/"
> + && (!className.contains("["))){ // class
> identifier doesn't contain "["
> + className = pkgPrefix + className; // add package
> + }
> + }
> + return className;
> + }
> +
>
> /**
> * Parse a signed integer of size bytes long.
>
>
> =====
>
>
> 2018-03-06 18:42 GMT+03:00 Kevin Looney <kevin.looney at oracle.com>:
>> Hello Maxim,
>>
>> Thanks for identifying the issue in asmtools.
>>
>>> The following patch address quoted class names handling bug in `asmtools
>>> jasm`.
>> Did you forget to attach the patch? - or are you simply reporting a problem
>> without a fix?
>>
>> Thanks in advance, Regards,
>> Kevin L
>> Manager - Conformance tools
>>
>>
>>
>> On 3/3/18 9:22 PM, Maxim Degtyarev wrote:
>>> The following patch address quoted class names handling bug in `asmtools
>>> jasm`.
>>>
>>> Quick example: Following code will produce class `TestQuoted` in
>>> top-level package ignoring package, specified by the "package"
>>> statement.
>>> After removing quotes around class name resulting class file will
>>> contain class `pkg.TestQuoted` as expected.
>>>
>>>
>>> package pkg;
>>>
>>> super public class "TestQuoted"
>>> version 52:0
>>> {
>>>
>>>
>>> public Method "<init>":"()V"
>>> stack 1 locals 1
>>> {
>>> aload_0;
>>> invokespecial Method java/lang/Object."<init>":"()V";
>>> return;
>>> }
>>>
>>> } // end Class TestQuoted
>>
>>
>> --
>> kevin.looney at oracle.com
>>
--
kevin.looney at oracle.com
More information about the code-tools-dev
mailing list