Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5173

ClassGenerator uses wrong constants to define child classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.0
    • None
    • None
    • None

    Description

      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:

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

      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:

      Modifier.FINAL = 0x10 = JMod.STATIC
      Modifier.PRIVATE = 0x02 = JMod.PROTECTED
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            paul-rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: