The compiler can throw a NullPointerException when trying to generate code which handles instances of anonymous or local classes. For example, if a rule is attached to a method of an anonymous class org.my.Foo$1 then the compiler will throw an NPE when compiling the term $0.
At certain points during generation of a compiled rule the compiler may need to insert the binary name of org.my.Foo$1 into the bytecode. It calls method Class.getCanonicalName to obtain the name of the class and converts this to binary form. However, this does not work for a local or anonymous class because getCanonicalName returns NULL.