Friday, August 5, 2016

Re: System.getProperty(...) - compile vs Eclipse plug-in difference (2.8b1)

We have static initialization as well, was just trying to illustrate the issue.  We ended up just removing the variable... it's actually in some "shared" code so we get funny looks when we ask for oddball syntax changes like this just to make GWT happy.

public class MyClass {

   public static final String PROP_VALUE = System.getProperty("myProperty"); // works in SDM and compilation

   public static final String STR_PROP = "myProperty";
   public static final String PROP_VALUE = System.getProperty(STR_PROP); // Does NOT work in SDM, but DOES work in compilation
    ...
}

I do not see a way of changing the optimization level thru SDM.  I've noticed a handful of compiler options that are not configurable when running thru SDM, these seem to be such options.  Tried -draft, -optimize 0, and -setProperty optimize=0 all triggering errors for SDM.  We do not set an optimization level at all currently, so the GWT-compiler must have a lower optimization level relative to SDM by default.  Perhaps a way to set the optimization level via SDM would be a minor enhancement?


On Thursday, August 4, 2016 at 4:28:57 PM UTC-7, Thomas Broyer wrote:
This might be due to the optimization level. What if you compile as -draft or -optimize 0?
FWIW, GWT tends to get system props in static initialization of constants, passing string literals as argument. I.e.
static final String PROP_VALUE = System.getProperty("myProperty");

On Thursday, August 4, 2016 at 9:35:05 PM UTC+2, clou...@gmail.com wrote:
Hi there,

Pretty simple example, but seems like possibly a bug or oddity in GWT 2.8b1 between the command line and the Eclipse plug in.

Setup: In a Module.gwt.xml file we define a property like so:
<define-property values="true,false" name="myProperty" />
<set-property name="myProperty" value="false" />

In a class we use it like so (paraphrased):
public class MyClass {
  
   public static final String STR_PROP = "myProperty";

   <SNIPS>

    public void foo() {
        String propValue = System.getProperty(STR_PROP);
        ....
    }
}

Behavior difference!
 - When we compile this on our command line, there is no error.
 - When we run thru SDM, the following error pops up:  [ERROR] Line 37: Only string constants may be used as property name in System.getProperty()

Does SDM just have an issue with the String constant used whereas the compiler itself does not? Bug? Intended? Suggestions? Thanks!

--
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 post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment