我目前正在使用此代码:
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.OFF);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
List<JSSourceFile> externs = new ArrayList<JSSourceFile>();
externs.add(JSSourceFile.fromFile(extern_src));
List<JSSourceFile> primary = new ArrayList<JSSourceFile>();
primary.add(JSSourceFile.fromFile(tmp));
compiler.compile(externs, primary, options);
但是,我收到很多这样的错误:
Error message: JSC_UNDEFINED_VARIABLE. variable Array is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable TypeError is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Object is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable arguments is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Number is undefined
Error message: JSC_UNDEFINED_VARIABLE. variable Math is undefined
显然,这些是不正确的:诸如此类Object
的东西arguments
是语言的核心部分。我能做些什么来解决这个问题?