Problem
With V8, any constant that isn't a String or primitive doesn't seem to be accessible from JavaScript -- they come across as undefined.
Is Rhino Broken [in this way] Too?
Nope.
Reproduction
Create a module (where "titanium" is an alias to the titanium.py in your 1.8.0.1 folder):
{quote}titanium create --type=module --name=booltest --id=ti.booltest --platform=android{quote}
My original test requires the following two file changes in the module. It tests for access to Boolean constants. See my comments down below for a more comprehensive, albiet less humorous, test.
Update the module's source file to the following:
package ti.booltest;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.titanium.TiApplication;
@Kroll.module(name="Booltest", id="ti.booltest")
public class BooltestModule extends KrollModule
{
@Kroll.constant public static final Boolean THE_SKY_IS_BLUE = true;
public BooltestModule()
{
super();
}
}
Update the app.js to the following:
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
win.add(Ti.UI.createLabel({
text: 'Papa! Papa! Is the sky blue?\n\n'
+ (require('ti.booltest').THE_SKY_IS_BLUE ? 'Yes! Just like your eyes, son.' : 'No! And while we\'re at it, Santa...')
}));
win.open();
Run the code on your device. You should see confirmation that the sky is, indeed, blue (in the form of a gripping father-son narrative). If you see slander against Santa, than we still have a problem that needs to be fixed.
While we're at it, let's test all the available constants.
Expanded Results
All the following work on Rhino. But ONLY STRINGS work on V8.Sorry for the misleading title. After further investigation, Rhino supports any sort of constants I throw at it. But V8 does not support any wrapped type variable (like Boolean, Integer, Float) EXCEPT for String. The primitive forms work great (int, bool, short, etc).