RFR: minor fix of DescriptorParser
Henry Jen
henry.jen at oracle.com
Wed Jun 6 13:44:49 UTC 2018
While investigating some other issue, I noticed nextToken(Token) is not throwing, turns out it was not implemented consistently.
Following is a patch that check expected Token as it should be current token as it was mostly used pattern. Although I feel the naming maybe a bit of unclear on that matter.
Anyhow, the patch allows the TestDescriptorGrammar.java to pass, and throw exception as it should.
Cheers,
Henry
diff -r 36a9696fad6e src/java.base/share/classes/jdk/internal/nicl/types/DescriptorParser.java
--- a/src/java.base/share/classes/jdk/internal/nicl/types/DescriptorParser.java Sun Jun 03 22:40:37 2018 -0700
+++ b/src/java.base/share/classes/jdk/internal/nicl/types/DescriptorParser.java Wed Jun 06 06:38:54 2018 -0700
@@ -51,10 +51,10 @@
}
void nextToken(Token expected) {
+ if (token != expected) {
+ throw scanner.error("expected: " + expected + "; found: " + token);
+ }
nextToken();
- if (token != expected) {
- scanner.error("expected: " + expected + "; found: " + token);
- }
}
/**
@@ -129,9 +129,9 @@
private Value parseValue() {
Value.Kind kind = lastKind();
Endianness endianness = lastEndianness();
- nextToken(Token.NUMERIC);
+ nextToken(Token.VALUE);
int size = parseSize();
- nextToken(); //NUMERIC
+ nextToken(Token.NUMERIC); //NUMERIC
Value value;
switch (kind) {
case INTEGRAL_UNSIGNED:
@@ -177,7 +177,7 @@
if (token != Token.EQ) {
return value;
}
- nextToken(Token.LBRACKET);
+ nextToken();
boolean prevAllowSubByteSizes = allowSubByteSizes;
try {
allowSubByteSizes = true;
@@ -282,7 +282,7 @@
* group = '[' (structOrUnionRest / sequenceRest) ']' [annotations]
*/
private Group parseGroup() {
- nextToken();
+ nextToken(Token.LBRACKET);
Group group;
if (token == Token.NUMERIC) {
group = parseSequenceRest();
More information about the panama-dev
mailing list