You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2016/12/31 00:06:58 UTC

[jira] [Created] (DRILL-5173) ClassGenerator uses wrong constants to define child classes

Paul Rogers created DRILL-5173:
----------------------------------

             Summary: ClassGenerator uses wrong constants to define child classes
                 Key: DRILL-5173
                 URL: https://issues.apache.org/jira/browse/DRILL-5173
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.8.0
            Reporter: Paul Rogers
            Priority: Minor


The code in {{ClassGenerator}} defines classes to generate using {{JCodeModel}}. Some templates, such as {{PartitionerTemplate}}, include nested classes which must also be generated. {{ClassGenerator}} creates definitions for these subclasses, but in so doing, uses the wrong constants for the class modifiers:

{code}
      String innerClassName = child.getSignatureClass().getSimpleName();
      JDefinedClass innerClazz = clazz._class(Modifier.FINAL + Modifier.PRIVATE, innerClassName);
{code}

The constants used come from Java's own {{Modifier}} introspection class. But, {{JCodeModel}} uses its own modifiers defined in {{JMod}}. Unfortunately, the values are not the same:

{code}
Modifier.FINAL = 0x10 = JMod.STATIC
Modifier.PRIVATE = 0x02 = JMod.PROTECTED
{code}

Hence, the code thinks it is asking for a non-static, {{private final}} class but is actually getting a {{static protected}} class.

The result is that the generated nested classes are declared static when they should be non-static inner classes. This issues causes compile errors when generating the code as "plain-old Java."

This bug is marked as lower priority because the current code, though wrong, works with the byte-code manipulations Drill uses today. It is a bug, however, because it is wrong in concept, and is wrong when generating plain-old Java.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)