Uploaded image for project: 'Byteman'
  1. Byteman
  2. BYTEMAN-394

Parser fails to recognize class literal expression as base for method or field access

      The following expression fails to parse

      System.out.println("Loader of Foo.class is " + Foo.class.getClassLoader());

      Bracketing the class literal makes it owrk

      System.out.println("Loader of Foo.class is " + (Foo.class).getClassLoader());

            [BYTEMAN-394] Parser fails to recognize class literal expression as base for method or field access

            Fixed

            Andrew Dinn added a comment - Fixed

            It's ok to support class literals as the base of method accesses. However, they need to be rejected as the base of field accesses because fields of Class are all private and are not accessible using reflection (that ensures that they can be lazily instantiated by the class as needed).

            The fix to the parser will accept both types of expressions. However, they need to increment the rule error count in the case of a field access, ensuring that the rule fails. Parsed method invocations will get interpreted and compiled as per usual so only the parser needs fixing.

            Andrew Dinn added a comment - It's ok to support class literals as the base of method accesses. However, they need to be rejected as the base of field accesses because fields of Class are all private and are not accessible using reflection (that ensures that they can be lazily instantiated by the class as needed). The fix to the parser will accept both types of expressions. However, they need to increment the rule error count in the case of a field access, ensuring that the rule fails. Parsed method invocations will get interpreted and compiled as per usual so only the parser needs fixing.

              rhn-engineering-adinn Andrew Dinn
              rhn-engineering-adinn Andrew Dinn
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: