QDox
  1. QDox
  2. QDOX-258

Definition of enum classes with constructor having parameters is not supported

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Given a enum
      Given that enum has a constructor.
      Given the constructor has some parameters
      When parsing the enum.
      Then a parsing exception is thrown.

        Activity

        Hide
        Iulian Zuzu added a comment - - edited

        A unit test for this bug is:

        public void testEnumWithConstructor()
           {
              final JavaProjectBuilder builder = new JavaProjectBuilder();
              final String source =
                    "package com.izuzu.something;"
                          + "   private enum Unit   {"
                          + "      KNOTS(1, Pattern.compile( \"N(\\d+)\" )),"
                          + "      MACH(SpeedConstants.MACH_TO_KNOTS / Unit.HUNDRED, Pattern.compile( \"M(\\d+)\" )),"
                          + "      KM(SpeedConstants.KMH_TO_KNOTS, Pattern.compile( \"K(\\d+)\" )),"
                          + "      NON_NUMERIC(0, Pattern.compile( \"[a-zA-Z]+\" ));"
                          + "      private static final int HUNDRED = 100;"
                          + "      private final double knotsFactor;"
                          + "      private final Pattern icaoSpeedPattern;"
                          + "      private Unit( final double knotsFactor, final Pattern icaoSpeedPattern )      {"
                          + "         this.knotsFactor = knotsFactor;"
                          + "         this.icaoSpeedPattern = icaoSpeedPattern;" + "      }" + "   }";
              builder.addSource( new StringReader( source ) );
           }
        
        Show
        Iulian Zuzu added a comment - - edited A unit test for this bug is: public void testEnumWithConstructor() { final JavaProjectBuilder builder = new JavaProjectBuilder(); final String source = " package com.izuzu.something;" + " private enum Unit {" + " KNOTS(1, Pattern.compile( \" N(\\d+)\ " ))," + " MACH(SpeedConstants.MACH_TO_KNOTS / Unit.HUNDRED, Pattern.compile( \" M(\\d+)\ " ))," + " KM(SpeedConstants.KMH_TO_KNOTS, Pattern.compile( \" K(\\d+)\ " ))," + " NON_NUMERIC(0, Pattern.compile( \" [a-zA-Z]+\ " ));" + " private static final int HUNDRED = 100;" + " private final double knotsFactor;" + " private final Pattern icaoSpeedPattern;" + " private Unit( final double knotsFactor, final Pattern icaoSpeedPattern ) {" + " this .knotsFactor = knotsFactor;" + " this .icaoSpeedPattern = icaoSpeedPattern;" + " }" + " }" ; builder.addSource( new StringReader( source ) ); }
        Hide
        Iulian Zuzu added a comment - - edited

        The full stack trace for the above is

        Exception in thread "main" com.thoughtworks.qdox.parser.ParseException: syntax error @[1,83]
        	at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:1683)
        	at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:1805)
        	at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:1664)
        	at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:205)
        	at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:162)
        	at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:91)
        	at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:86)
        	at com.thoughtworks.qdox.library.SortedClassLibraryBuilder.addSource(SortedClassLibraryBuilder.java:161)
        	at com.thoughtworks.qdox.JavaProjectBuilder.addSource(JavaProjectBuilder.java:173)
        
        Show
        Iulian Zuzu added a comment - - edited The full stack trace for the above is Exception in thread "main" com.thoughtworks.qdox.parser.ParseException: syntax error @[1,83] at com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:1683) at com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:1805) at com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:1664) at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:205) at com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:162) at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:91) at com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:86) at com.thoughtworks.qdox.library.SortedClassLibraryBuilder.addSource(SortedClassLibraryBuilder.java:161) at com.thoughtworks.qdox.JavaProjectBuilder.addSource(JavaProjectBuilder.java:173)
        Hide
        Iulian Zuzu added a comment -

        The affected version is <qdox.version>2.0-M2</qdox.version>

        Show
        Iulian Zuzu added a comment - The affected version is <qdox.version>2.0-M2</qdox.version>
        Hide
        Robert Scholte added a comment -

        Seems like some parts of http://docs.oracle.com/javase/specs/jls/se8/html/jls-19.html aren't fully implemented yet. A patch with a fix would be welcome.

        Show
        Robert Scholte added a comment - Seems like some parts of http://docs.oracle.com/javase/specs/jls/se8/html/jls-19.html aren't fully implemented yet. A patch with a fix would be welcome.

          People

          • Assignee:
            Unassigned
            Reporter:
            Iulian Zuzu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: