Closed
Bug 431674
Opened 16 years ago
Closed 16 years ago
Java field private access doesn't work well with Java Bean access
Categories
(Rhino Graveyard :: Core, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: norrisboyd, Unassigned)
Details
Automagic property access -- and when it's a bit too magical Let's say you have a Java class with a standard getFoo/setFoo pair of methods. Rhino lets automatically unmangles the names and let you write code like this: var aFooHolder = new JavAFooHolder(); aFooHolder.foo = 'kung'; print(aFooHolder.foo); // prints 'kung' Magical! But wait, theres (unfortunately) more. Under some circumstances (what are these?) Rhino will also see private class variables. Even more unfortuantely, it seems to prefer the private member variables to the demangled property-access methods. This can bite you like a black mamba on a sunless Serengetti night. Let's say that the FooHolder?'s setFoo method has Important Side Effects: var aFooHolder = new JavAFooHolder(); aFooHolder.foo = 'kung'; // should also close the Exhaust Port leading to the reactor core print(aFooHolder.foo); // prints 'kung', because the private member variable is set correctly assertFalse(ExhaustPort.isOpen); // Augh! We're wide open to Rebel attack! This can be maddening, because the member variable appears to have been 'set' but it was really inserted with a needle. Beware!
Reporter | ||
Comment 1•16 years ago
|
||
Fixed: Checking in src/org/mozilla/javascript/JavaMembers.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/JavaMembers.java,v <-- JavaMembers.java new revision: 1.77; previous revision: 1.76 done Checking in testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java; /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/JavaAcessibilityTest.java,v <-- JavaAcessibilityTest.java new revision: 1.4; previous revision: 1.3 done Checking in testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java; /cvsroot/mozilla/js/rhino/testsrc/org/mozilla/javascript/tests/PrivateAccessClass.java,v <-- PrivateAccessClass.java new revision: 1.4; previous revision: 1.3 done
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•