I am working on a JVM-based programming language and I use Byte Buddy for the code generator. The language is somewhat similar to Java but typically uses annotations where Java would use keywords. Some example annotations are public
, private
, extends
, override
, singleton
or inject
.
Unlike the Java Language Specification, the Java Virtual Machine Specification imposes very few restrictions on class names, and names like extends
or public
are perfectly valid from JVM-perspective.
However, when I try to generate annotation classes with a name that happens to be a Java keyword I get an IllegalStateException
"Illegal type name
" from Byte Buddy's InstrumentedType
class.
How can I circumvent the validation that is specific to the Java language and use more lenient validation rules that follow the Java Virtual Machine Specification instead?