mjscosta / gwtx

Automatically exported from code.google.com/p/gwtx
0 stars 0 forks source link

Invalid JSNI reference in Pattern.java #25

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Upgrade an application that is using gwtx-1.5.2.jar to GWT 2.0
2. Compile the application.
3. Read the resulting error messages

What is the expected output? What do you see instead?
Expecting no compilation errors.  Instead, we get 
somethig like this:

14:40:55.873 [WARN] [kbit] Warnings in 'jar:file:/D:/GWT/gwt-keinavo- 
external-library/gwtx-1.5.2.jar!/com/googlecode/gwtx/java/util/emul/ 
java/util/regex/Pattern.java' 
14:40:55.904 [WARN] [kbit] Line 140: Referencing class 
'com.googlecode.gwtx.java.util.emul.java.util.regex.Pattern': unable 
to resolve class, expect subsequent failures 
14:40:55.935 [WARN] [kbit] Line 149: Referencing class 
'com.googlecode.gwtx.java.util.emul.java.util.regex.Pattern': unable 
to resolve class, expect subsequent failures 
14:40:55.966 [WARN] [kbit] Line 183: Referencing class 
'com.googlecode.gwtx.java.util.emul.java.util.regex.Pattern': unable 
to resolve class, expect subsequent failures 
14:40:55.982 [WARN] [kbit] Line 194: Referencing class 
'com.googlecode.gwtx.java.util.emul.java.util.regex.Pattern': unable 
to resolve class, expect subsequent failures 

What version of the product are you using? On what operating system?
Version 1.5.2 on Windows Vista Ultimate.  With GWT 2.0.

Please provide any additional information below.

This problem has been reported and fixed before multiple times (see issues 
22 and 18), and so it appears to be a recurring one.

I believe that I have now surmounted this problem, thanks largely to a 
developer who posted a fix to the issue 18 thread, which is referenced from 
the main GWTx page (with a line through it indicating that it had been 
fixed, although that fix does not seem to have held through the latest GWT 
release):

http://code.google.com/p/gwtx/issues/detail?id=18

The issue seems to be that the problematic class (Pattern) is making a 
number of references via JSNI to Javascript elements that are generated by 
the GWT compiler, but the compiler seems to have changed the way in which 
it generates the names of these elements (perhaps due to the new 2.0 
features that provide more rigorous obfuscation through renaming - that is 
just a guess), and as a result these references to native elements are 
incorrect.

The developer who addressed this issue in the abovementioned post fixed the 
problematic references and posted his fixed version of the entire 
Pattern.java source file to the above-referenced message on GWTx.

Note that his message was posted on November 6, 2009, before the official 
release of GWT 2.0, and so apparently the earlier 1.7.1 release of GWT that 
I was using prior to this version update did not flag this as an issue and 
indeed it may not have been an issue for that release.  It is possible that 
this developer was working with an intermediate or advance release.

The details of GWT's mappings to Javascript are beyond my present level of 
experience, and so I cannot claim to understand this fix at a detailed 
level, but it is clear that the exact lines that are flagged by the 
compiler in the error messages that I have printed above are the lines that 
were fixed by this patch.

Anyway, I downloaded the Pattern.java file so nicely attached by the 
developer (one darek.kobylarz), looked it over,
and then unzipped the gwt-1.5.2.jar file, replaced Pattern.java with the 
new Pattern.java, and then zipped it back up using the jar tool, creating a 
new archive called gwt-1.5.2-patched.jar.  I then replaced my project's 
reference to the old archive with a reference to the new archive, and, 
voila! no more compiler complaints.  And, presumably (hopefully) working 
code, too.

I did some basic testing of my site and all seems to be well, but that is 
not a guarantee! Remember that my understanding of this problem and of the 
fix posted is rudimentary, and so you must take steps to satisfy yourself 
that this solution is a good one.  But, so far it is looking like a fix to 
me.

One more thought is that if you look at the message thread, this looks like 
a recurring problem, and a wild guess would be that each time GWT changes 
its naming conventions, it breaks this code.  But maybe Derek's fix is more 
secure than the others, since he is no longer using hard-coded names.  
Anyway, if you do use his fix, then in future releases, you might want to 
keep an eye on this code to see if it breaks again.

It does seems a little strange that GWTx has not provided a new release for 
this and it may be because the issue thread to which
the developer posted his corrected Pattern.java file was closed in February 
of 2009, and so maybe nobody realizes that there is this issue with 2.0, 
although it seems strange that no one would have noticed, unless this only 
produces an error under special circumstances.

One other developer besides me has posted a note (elsewhere) that he has 
encountered this problem.  So, perhaps it is only revealed when certain 
GWTx features are used.

Carl

Original issue reported on code.google.com by goalst...@gmail.com on 9 Jan 2010 at 12:12

GoogleCodeExporter commented 9 years ago
I also had this problem - and with gwt 2.2 it even becomes worese: GWT reports 
an ERROR instead of just a WARNING. I used to modified Pattern.java from issue 
18.

Original comment by googelyb...@gmail.com on 30 Mar 2011 at 3:43

GoogleCodeExporter commented 9 years ago
Is this project even active anymore? Here I am on 7 September 2011 commenting 
on an issue reported on  9 Jan 2010. I took gwtx-1.5.2.jar and added it to my 
project and I'm now getting this error:

[ERROR] Line 140: Referencing class 
'com.googlecode.gwtx.java.util.emul.java.util.regex.Pattern': unable to resolve 
class.

Yes, I will modify the jar with the fixed Pattern.java, but you should either 
remove your built jar file or fix and re-post it. I'm not even trying to use 
the class that's causing the error, so everyone should see this error when 
compiling a project with gwtx-1.5.2.jar included. The GWT compile completes 
with a "Compilation succeeded" message, but I can't believe you actually tested 
this, which leads me to wonder if I should trust this code. 

Original comment by robertt...@gmail.com on 7 Sep 2011 at 6:12

GoogleCodeExporter commented 9 years ago
The project is not active due to lack of spare time, but is open to every 
volunteer to become committer

Original comment by ndel...@cloudbees.com on 8 Sep 2011 at 7:32