While investigating how Rhino loads Java packages I came across what
appears to be a "typo" bug in NativeJavaTopPackage.java; a missing
semicolon in a string results in minor performance degradation for
script accessing the java.lang.reflect and java.lang.io packages.
- Fix XMLToXMLString bug where ancdecls was not updated with a weak ref append
when a namespace strong ref was appended to decls. In ECMA-357, ancdecls is
written out as (AncestorNamespaces U namespaceDeclarations), but here where
ancestorNSes and decls are unioned early into ancdecls, we need to update
the unioned set whenever decls is updated.
- Fix ECMA-357 glitch (suboptimal, arguably not an erratum) in ToXMLString
where XML that uses the default namespace only is converted via toXMLString
into a string serialization that redeclares that namespace using generated
prefixes, for every node in the tree. This is verbose, inefficient, and
unnecessary. A trivial tweak to 10.2.1 Step 12(a), to let namespace.prefix
be the empty string if x.[[Name]].[[Prefix]] is undefined, fixes the bug.
- Const-ipate JSXMLArray * parameters starting with XMLToXMLString's, to be
sure no one appends a strong ref to a weak-ref-holding |in| parameter.
In this way when native code implementing host objects calls Context.jsToJava the exception can be caught in JS and processed in in the same way as exceptions resulting from bad calls to LiveConnect Java objects.
ECMA-357 botch where * or @b or (given valid namespace reference n) n::id
results in undefined, instead of a TypeError.
- Lazily bootstrap AnyName and AttributeName classes, instead of leaving the
former uninitialized, and initializing the latter only if QName is init'ed.
These classes, representing ECMA-357 internal types, must be initialized
in order to string conversion and default value on them to return useful
results. So this change also requires the shared qname_toString to cope
with these classes, which ape QName in having a JSXMLQName as private data.
- Revise Filtering Predicate Expressions bytecode schema to avoid bogo-script
creating in js_FilterXMLObject. With a new JSOP_ENDFILTER bytecode acting
in lieu of JSOP_POPV, but also exiting the nested js_Interpret() call, the
runtime can avoid trying to fake a JSScript for the subsequence of script
bytecode in parens in x.(e), that contains the bytecode for e plus the pop
or endfilter op.
This requires a historic reparameterization of js_Interpret to take the
starting pc! I cleaned up order of declaration, use, and useless init nits
for a few variables while messing with it.
- Based on the above change, fix the decompiler to handle filtered predicate
expressions -- that code was stubbed out till now, and I forgot to go back.
All better now, especially thanks to JSOP_ENDFILTER.
- Also while fixing filtered predicates, eliminate the useless TOK_RP parse
node above the parenthesized expression, to avoid a JSOP_GROUP bytecode.
- Fix js_GetAttributeNameObject so it doesn't take over its QName parameter's
object and rebind it to an object of class AttributeName -- instead, clone
the qn if necessary. This is important to cope with the errata, noticed a
while ago but finally recorded:
9.2.1.2 Step 2(e)(i, ii),
9.2.1.2 Step 7(e)(i),
9.2.1.3 Step 2(b)(ii)(1)(a)
All uses of a.[[Name]] for an attribute a in these sections that pass
that QName object to [[Delete]] must pass an AttributeName cloned from
a.[[Name]]. The [[Name]] internal property is always a QName instance
and never an AttributeName or AnyName instance. But [[Delete]] will
not operate on x.[[Attributes]] when given a QName by these sections,
so a child could be wrongly deleted instead of the attribute of the
same name.
This rework exposed a bug in the XML.prototype.name() impl, where it was
returning an AttributeName, not a QName, for attribute-class XML objects.
Clearly wrong -- the E4X spec makes plain early on that [[Name]] is always
a QName -- but the spec and e4x testsuite seemed to require it due to the
above-noted errata.