Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6905829

Fix for 6225552 should be integrated correctly in jdk5ux

XMLWordPrintable

    • b05
    • x86
    • linux_redhat_4.0
    • Verified

        A JavaSE licensee faces with following exception during XSL conversion in jdk5u13.

        ---
        java.lang.NoSuchMethodError:
           GregorSamsa.PrintSpaceImageTag(Lcom/sun/org/apache/xalan/internal/xsltc/DOM;Lcom/sun/org/apache/xml/internal/dtm/DTMAxisIterator;Lcom/sun/org/apache/xml/internal/serializer/SerializationHandler;I)V
            at GregorSamsa.template$dot$0()
            at GregorSamsa.applyTemplates()
            at GregorSamsa.applyTemplates()
            at GregorSamsa.transform()
            at com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:594)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:663)
            at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:300)
        ...
        ---

        CONFIGURATION :
        JDK : 5.0u13/5.0u22
        OS : linux


        INVESTIGATION:

        This seems the same to 6225552 and caused from incomplete integration of the fix for 6225552 in jdk5.

        There is the following portion in the diff. for 6225552 in JAXP1.3.1.

        ==== diff in ./src/org/apache/xalan/xsltc/compiler/Stylesheet.java ==
        ...
        1380 + Vector templates = new Vector();
        1381 + templates.addAll(_templates);
        ...
        ====

        The corresponding portion in jdk5 are line#1390 and 1391.
        At line#1391( *1 in the following code protion),
        there seem needed '_' (underscore) in front of "template" variable in the curly brackets.

        -- JDK5u22 ---
        [j2se/src/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/Stylesheet.java]
        1381
        1382 public Vector getAllValidTemplates() {
        1383 // Return templates if no imported/included stylesheets
        1384 if (_includedStylesheets == null) {
        1385 return _templates;
        1386 }
        1387
        1388 // Is returned value cached?
        1389 if (_allValidTemplates == null) {
        1390 Vector templates = new Vector();
        1391 templates.addAll(templates); //*1 : '_' seems needed in front of "templates" in brackets
        1392 int size = _includedStylesheets.size();
        1393 for (int i = 0; i < size; i++) {
        1394 Stylesheet included =(Stylesheet)_includedStylesheets.elentAt(i);
        1395 templates.addAll(included.getAllValidTemplates());
        1396 }
        1397 // templates.addAll(_templates);
        1398
        1399 // Cache results in top-level stylesheet only
        1400 if (_parentStylesheet != null) {
        1401 return templates;
        1402 }
        1403 _allValidTemplates = templates;
        1404 }
        1405
        1406 return _allValidTemplates;
        1407 }
        ----------------------


        The exception occurs in the following scenario.

        In this case, template included stylesheet is not included in return value.
        "If" statement at the following *2 line in CallTemplate#translate() method checks incorrectly,
        the signature to call template can not be created correctly.(at the following *3 )

        === [j2se/src/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/CallTemplate.java] ===
              public void translate(ClassGenerator classGen, MethodGenerator methodGen) {
                final Stylesheet stylesheet = classGen.getStylesheet();
                final ConstantPoolGen cpg = classGen.getConstantPool();
                final InstructionList il = methodGen.getInstructionList();

                  // If there are Params in the stylesheet or WithParams in this call?
                if (stylesheet.hasLocalParams() || hasContents()) { // *2: There is possibility to check incorrectly.
                    _calleeTemplate = getCalleeTemplate();
                    ...
                }
                ...

                  // Initialize prefix of method signature
                StringBuffer methodSig = new StringBuffer("(" + DOM_INTF_SIG
                      + NODE_ITERATOR_SIG + TRANSLET_OUTPUT_SIG + NODE_SIG);

                  // If calling a simply named template, push actual arguments
                if (_calleeTemplate != null) { // "if" statement at teh above *2 checks incorrectly,
                                                        // this block might not be excuted.
                                                        // Then needed signatures will not be appended.
                    Vector calleeParams = _calleeTemplate.getParameters();
                    int numParams = _parameters.length;

                    for (int i = 0; i < numParams; i++) {
                        SyntaxTreeNode node = (SyntaxTreeNode)_parameters[i];
                          methodSig.append(OBJECT_SIG); // append Object to signature

                          // Push 'null' if Param to indicate no actual parameter specified
                          if (node instanceof Param) {
                              il.append(ACONST_NULL);
                          }
                          else { // translate WithParam
                              node.translate(classGen, methodGen);
                          }
                      }
                  }

                  // Complete signature and generate invokevirtual call
                methodSig.append(")V");
                il.append(new INVOKEVIRTUAL(cpg.addMethodref(className,
                                                             methodName,
                                                             methodSig.toString()))); // *3 : This might call methods with wrong signature

        ------------

        NOTE:
          In jdk6u17, "template" variable has been changed correctly.

        ---->
        ....
          1377 public Vector getAllValidTemplates() {
          1378 // Return templates if no imported/included stylesheets
          1379 if (_includedStylesheets == null) {
          1380 return _templates;
          1381 }
          1382
          1383 // Is returned value cached?
          1384 if (_allValidTemplates == null) {
          1385 Vector templates = new Vector();
          1386 templates.addAll(_templates); // Changed correctly
          1387 int size = _includedStylesheets.size();
          1388 for (int i = 0; i < size; i++) {
          1389 Stylesheet included =(Stylesheet)_includedStylesheets.elementAt(i);
        ....
        <---

              asaha Abhijit Saha
              tbaba Tadayuki Baba (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: