File tree Expand file tree Collapse file tree
rhino/src/main/java/org/mozilla/javascript/optimizer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import java .util .HashMap ;
1818import java .util .List ;
1919import java .util .Map ;
20+ import java .util .regex .Pattern ;
2021import org .mozilla .classfile .ByteCode ;
2122import org .mozilla .classfile .ClassFileWriter ;
2223import org .mozilla .javascript .CodeGenUtils ;
@@ -860,6 +861,12 @@ String getBodyMethodName(ScriptNode n, int index) {
860861 return "_c_" + cleanName (n ) + "_" + index ;
861862 }
862863
864+ /**
865+ * List of illegal characters in unqualified names as specified in
866+ * https://docs.oracle.com/javase/specs/jvms/se25/html/jvms-4.html#jvms-4.2.2
867+ */
868+ private static Pattern illegalChars = Pattern .compile ("[.;\\ [/<>]" );
869+
863870 /** Gets a Java-compatible "informative" name for the ScriptOrFnNode */
864871 String cleanName (final ScriptNode n ) {
865872 String result = "" ;
@@ -873,7 +880,7 @@ String cleanName(final ScriptNode n) {
873880 } else {
874881 result = "script" ;
875882 }
876- return result ;
883+ return illegalChars . matcher ( result ). replaceAll ( "_" ) ;
877884 }
878885
879886 String getNonDirectBodyMethodSIgnature (ScriptNode n ) {
You can’t perform that action at this time.
0 commit comments