Robert Reiner created QDOX-240:
----------------------------------

             Summary: Enum constructors with new Object Instances or method 
calls fail with a parser exception
                 Key: QDOX-240
                 URL: https://jira.codehaus.org/browse/QDOX-240
             Project: QDox
          Issue Type: Bug
          Components: Parser
    Affects Versions: 2.0-alpha
         Environment: Java 6, qdox-2.0-alpha-1
            Reporter: Robert Reiner


I try to parse enumerations with constants that call a constructor/method, but 
it fails with a parse error.

I'm using qdox-2.0-alpha-1. These are the two test cases that fail:

==========
1. Calling a constructor:

package simpleenum;

import java.util.Date;

public enum MinimalEnumExampleConstructor
{
  D_CONSTRUCTOR(new Date());         // FAILS to be parsed

  private final Date date;

  private MinimalEnumExampleConstructor(final Date date)
  {
    this.date = date;
  }
}

Parse error: com.thoughtworks.qdox.parser.ParseException: syntax error @[7,21] 
in file:/[snipped]/MinimalEnumExampleConstructor.java

==========
2. Calling a method (probably the same root cause)

package simpleenum;

import java.util.Date;

public enum MinimalEnumExampleMethod
{
  D_METHOD(create());            // FAILS to be parsed

  private final Date date;

  private MinimalEnumExampleMethod(final Date date)
  {
    this.date = date;
  }

  public static Date create()
  {
    return new Date();
  }
}

Parse error: com.thoughtworks.qdox.parser.ParseException: syntax error @[7,19] 
in file:/[snipped]/MinimalEnumExampleMethod.java
==========



If I define a constant (e.g. for the Date instance above), the parsing 
completes successfully:

public enum EnumExample ... {
  D_CONSTANT(X.Y);       // parsing successful
 ...
}

public class X {
  public static final Date Y = new Date();
}

SUCCESS



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to