-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Labels
Description
A rule that is declared "static" causes a "java.lang.VerifyError" during parser generation. Instead Grappa should either support this or else should generate a proper error message.
$ gradle
:compileJava
Download http://repo1.maven.org/maven2/com/github/fge/grappa/2.0.0/grappa-2.0.0.jar
:processResources UP-TO-DATE
:classes
:run
Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
Location:
app/Main$Parser$$grappa.rule()Lcom/github/fge/grappa/rules/Rule; @0: aload_0
Reason:
Type top (current frame, locals[0]) is not assignable to reference type
Current Frame:
bci: @0
flags: { }
locals: { }
stack: { }
Bytecode:
0x0000000: 2ab4 01a1 59c6 0004 b057 bb00 3059 b700
0x0000010: 3459 2a5f b501 a12a b701 a359 c600 0b13
0x0000020: 01a4 b900 4702 005a c000 49b6 004d 592a
0x0000030: 5fb5 01a1 b0
Stackmap Table:
same_locals_1_stack_item_frame(@9,Object[#67])
full_frame(@39,{},{Object[#48],Object[#67]})
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2663)
at java.lang.Class.getConstructors(Class.java:1643)
at com.github.fge.grappa.Grappa.findConstructor(Grappa.java:111)
at com.github.fge.grappa.Grappa.createParser(Grappa.java:67)
at app.Main.main(Main.java:12)
:run FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command '/usr/local/java/64/jdk1.8.0_31/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.967 secs
$ cat build.gradle
defaultTasks 'run'
apply plugin: 'application'
apply plugin: 'java'
sourceCompatibility = 1.8
mainClassName = 'app.Main'
dependencies {
compile 'com.github.fge:grappa:2.0.0'
}
repositories {
mavenCentral()
}
$ cat src/main/java/app/Main.java
package app;
import com.github.fge.grappa.Grappa;
import com.github.fge.grappa.buffers.CharSequenceInputBuffer;
import com.github.fge.grappa.parsers.BaseParser;
import com.github.fge.grappa.rules.Rule;
import com.github.fge.grappa.run.ListeningParseRunner;
public class Main {
public static void main(final String[] args) {
new ListeningParseRunner<>(Grappa.createParser(Parser.class).rule()).run(new CharSequenceInputBuffer("a"));
}
public static class Parser extends BaseParser<Object> {
public static Rule rule() {
return ANY;
}
}
}