Details
Description
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
Activity
Robert Scholte
made changes -
Field | Original Value | New Value |
---|---|---|
Description |
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 |
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: {code} 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; } } {code} {{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) {code} 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(); } } {code} {{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: {code} public enum EnumExample ... { D_CONSTANT(X.Y); // parsing successful ... } public class X { public static final Date Y = new Date(); } {code} {{SUCCESS}} |
Robert Scholte
made changes -
Resolution | Fixed [ 1 ] | |
Fix Version/s | 2.0 [ 15636 ] | |
Assignee | Robert Scholte [ rfscholte ] | |
Status | Open [ 1 ] | Resolved [ 5 ] |
With rev. 1492 rev. 1493 the parsing problems of the testcases have been solved.
I still have to make them part of the model, so sources can be regenerated.
I leave this issue open until that is fixed too.