JDK-6612541 : api/javax_swing/text/LabelView/index.html#getXXX[LabelView0004] fails since JDK 7 b20
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 7
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-10-03
  • Updated: 2012-03-22
  • Resolved: 2009-11-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b68Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
JCK: JCK-runtime-6b b07
J2SE: FAIL - 7 b20 PASS 7 b19 6u4 b03 
Platform[s]: FAIL -  All
switch/Mode: FAIL - default

Test api/javax_swing/text/LabelView/index.html#getXXX[LabelView0004] fails since JDK 7. the problem is getBreakWeight starts to return View.BadBreakWeight.

Steps to reproduce:

run the following code:



import java.awt.*;
import javax.swing.*;
import java.io.PrintWriter;
import javax.swing.*;
import javax.swing.text.*;


public class Test {

    /* standalone interface */
    public static void main(String argv[]) {

        System.out.println(" === public int getBreakWeight(int axis, float pos, float len) === ");
        Element element = new StubElement("StubElement");
        LabelView c = new LabelView(element);
        int axis = View.X_AXIS;
        float pref = c.getPreferredSpan(axis); // To update metrics parameters.
        int pos = 0;
        int len = 2;
        int weight = c.getBreakWeight(axis, pos, len);

        if (!(weight == View.BadBreakWeight)) {
            System.out.println("  Should return " + View.BadBreakWeight);
            System.out.println("   but has returned " + weight);
            System.out.println("public int getBreakWeight(int axis, float pos, float len) Test Failed");
        }
        pos = 23;
        len = 48;
        weight = c.getBreakWeight(axis, pos, len);

        if (weight == View.BadBreakWeight) {
            System.out.println("  Should return value more then " + View.BadBreakWeight);
            System.out.println("   but has returned " + weight);
            System.out.println("public int getBreakWeight(int axis, float pos, float len) Test Failed");
        }
        System.out.println("OKAY");
    }
}



class StubElement implements Element {
    Document document = new DefaultStyledDocument();
    String context;
    public SimpleAttributeSet attr;

    public StubElement(String context) {
        this.context = context;
        attr = new SimpleAttributeSet();
        document = new DefaultStyledDocument();
        try {
            document.insertString(0, context, new SimpleAttributeSet());
        } catch (BadLocationException e) {}
    }

    public Document getDocument() {
        return document;
    }

    public Element getParentElement() {
        return null;
    }

    public String getName() {
        return "StubElement";
    }

    public AttributeSet getAttributes() {
        return attr;
    }

    public int getStartOffset() {
        return 0;
    }

    public int getEndOffset() {
        return document.getLength();
    }

    public int getElementIndex(int offset) {
        return 0;
    }

    public int getElementCount() {
        return 1;
    }

    public Element getElement(int index) {
        return this;
    }

    public boolean isLeaf() {
        return true;
    }

    /**
     * Return the difference between getStartOffset() and
     * getEndOffset().
     */
    public int getLineLimit() {
        return getEndOffset() - getStartOffset();
    }
}

Comments
EVALUATION Verified test cases pass in jdk1.6.0_17b04 and jdk1.7.0b76
17-11-2009

EVALUATION Until the custom break iterators are implemented, restore the old behavior to make the JCK test pass.
14-07-2009

EVALUATION This will be fixed indirectly when the 4644241 "Need API to set BreakIterator of JTextComponent" is implemented. The change in behavior is caused by the fix for 6423287 "PargraphView returns wrong minimum span."
19-10-2007