athena
athena

Reputation: 5709

JavaCC: Too many warnings

I am using JavaCC version 5.0. with Eclipse Galileo.

But when I set option "static=true" in my jj file, the generated TokenManager file has many warnings like "The static method readChar() from the type SimpleCharStream should be accessed in a static way". Also, all the imports from my jj file have been copied over to the TokenManager, where they are flagged as unused. Is there an option to prevent this?

It seems this issue was fixed in JavaCC v4.1, then why do I still face this?

Upvotes: 2

Views: 801

Answers (2)

Apalala
Apalala

Reputation: 9224

JavaCC does not delete existing generated classes when you switch it to static. That behaviour is in case you've made changes to the classes, or provided your own versions.

Delete all generated classes, set 'static=true', and start again. Everything should work.

If you're automating builds (like with Ant), it would be good idea to always delete and regenerate JavaCC generated classes, just to make sure that what you're testing is reproducible.

As to Eclipse... You can tell it to run your Ant script when you've made changes to the JavaCC input files.

Upvotes: 1

fbafelipe
fbafelipe

Reputation: 4952

Those warnings are due to code that is correct but not recommended. Since it won't be a good idea to go fixing generated code by hand, my suggestion is to disable those warnings in Eclipse (Java > Compiler > Error/Warnings).

I recommend you to use project specific settings to disable those warnings (so it won't disable in all your projects), you can also put all the generated code in a project and make your code depend on this project, so you can keep those warnings for your code.

Upvotes: 0

Related Questions