Looking at https://github.com/gwtproject/gwt/blob/4d36d55d26aabc12e4429faf0603c539a54a13cd/dev/core/src/com/google/gwt/dev/js/rhino/TokenStream.java#L1251-L1265 which parses the regexp, it looks like you'd have to escape the '/' so it's not mistaken for the end of the regexp:
(btw, not sure you really want \\w here)
On Monday, July 29, 2019 at 9:57:09 AM UTC+2, Qin Binghua wrote:
-- from:
var reg = /^[\\w+/_-]+[=]{0,2}$/
to
var reg = /^[\\w+\/_-]+[=]{0,2}$/
(btw, not sure you really want \\w here)
On Monday, July 29, 2019 at 9:57:09 AM UTC+2, Qin Binghua wrote:
Hello everyone,To simplify the description of the problem, I use an official example to illustrate the problem。
- Follow the GWT Getting Started to create a GWT project
webAppCreator -out MyWebApp com.mycompany.mywebapp.MyWebApp - Define a JSNI method with java regular expression and call it in the EntryPoint class com.mycompany.mywebapp.client.
MyWebApp
public static native void methodWithRegularExpression()/*-{ var reg = /^[\\w+/_-]+[=]{0,2}$/console.log("reg:" + reg)}-*/;/*** This is the entry point method.*/public void onModuleLoad() {methodWithRegularExpression();}- Compile the project with the following Ant task(gwtc)
<!-- Arguments to gwtc and devmode targets --><property name="gwt.args" value="" /><!-- Configure path to GWT SDK --><property name="gwt.sdk" location="G:/Google/gwt-2.8.2" /><path id="project.class.path"><fileset dir="lib" includes="**/*.jar"/><pathelement location="war/WEB-INF/classes"/> <pathelement location="${gwt.sdk}/gwt-user.jar"/> <pathelement location="${gwt.sdk}/gwt-dev.jar"/> <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA.jar"/> <pathelement location="${gwt.sdk}/validation-api-1.0.0.GA- sources.jar"/> <fileset dir="war/WEB-INF/lib" includes="**/*.jar"/><!-- Add any additional non-server libs (such as JUnit) here --></path><target name="libs" description="Copy libs to WEB-INF/lib"><mkdir dir="war/WEB-INF/lib" /><copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" /> <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet-deps.jar" /> <!-- Add any additional server libs that need to be copied --></target><target name="javac" depends="libs" description="Compile java source to bytecode"><mkdir dir="war/WEB-INF/classes"/><javac srcdir="src" includes="**" encoding="utf-8"destdir="war/WEB-INF/classes"source="1.7" target="1.7" nowarn="true"debug="true" debuglevel="lines,vars,source"> <classpath refid="project.class.path"/></javac><copy todir="war/WEB-INF/classes"><fileset dir="src" excludes="**/*.java"/></copy></target><target name="gwtc" depends="javac" description="GWT compile to JavaScript (production mode)"><java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler" maxmemory="512m"> <classpath><pathelement location="src"/><path refid="project.class.path"/></classpath><arg line="-war"/><arg value="war"/><!-- Additional arguments like -style PRETTY or -logLevel DEBUG --><arg line="${gwt.args}"/><arg line="-strict"/><arg value="com.mycompany.mywebapp.MyWebApp"/> </java></target>- Build failed
javac:[javac] G:\Google\MyWebApp\build.xml:34: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to G:\Google\MyWebApp\war\WEB-INF\classes gwtc:[java] 七月 29, 2019 10:31:07 上午 java.util.prefs.WindowsPreferences <init> [java] 警告: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.[java] Compiling module com.mycompany.mywebapp.MyWebApp [java] Tracing compile failure path for type 'com.mycompany.mywebapp.client.MyWebApp' [java] [ERROR] Errors in 'file:/G:/Google/MyWebApp/src/com/mycompany/mywebapp/client/ MyWebApp.java' [java] [ERROR] Line 44: missing ; before statement[java] > var reg = /^[\\w+/_-]+[=]{0,2}$/[java] > ---------------------------^[java] Finding entry point classes[java] Tracing compile failure path for type 'com.mycompany.mywebapp.client.MyWebApp' [java] [ERROR] Errors in 'file:/G:/Google/MyWebApp/src/com/mycompany/mywebapp/client/ MyWebApp.java' [java] [ERROR] Line 44: missing ; before statement[java] > var reg = /^[\\w+/_-]+[=]{0,2}$/[java] > ---------------------------^[java] [ERROR] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properlyBUILD FAILEDMore information:ant version:Apache Ant(TM) version 1.9.14 compiled on March 12 2019GWT SDK version:2.8.2In the end, does anyone know how to solve this problem?
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/a7751b4a-3c92-44bd-b379-e255f27db3a6%40googlegroups.com.
No comments:
Post a Comment