From: <k_s...@us...> - 2008-09-08 22:11:51
|
Revision: 13622 http://jedit.svn.sourceforge.net/jedit/?rev=13622&view=rev Author: k_satoda Date: 2008-09-08 22:11:47 +0000 (Mon, 08 Sep 2008) Log Message: ----------- Add a workaround for a bug in Sun Java 5, because jEdit 4.3 should run on Java 5. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6266084 Modified Paths: -------------- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java Modified: jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java =================================================================== --- jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2008-09-08 03:02:36 UTC (rev 13621) +++ jEdit/trunk/org/gjt/sp/jedit/syntax/Chunk.java 2008-09-08 22:11:47 UTC (rev 13622) @@ -308,7 +308,21 @@ str = new String(seg.array,seg.offset + offset,length); + char[] textArray = seg.array; int textStart = seg.offset + offset; + // {{{ Workaround for a bug in Sun Java 5 + // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6266084 + if (SUN_JAVA_5) + { + // textLimit is used as a text count in + // layoutGlyphVector(). So it works only the + // case textStart is 0. + char[] copy = new char[length]; + System.arraycopy(textArray, textStart, + copy, 0, length); + textArray = copy; + textStart = 0; + } //}}} int textLimit = textStart + length; // FIXME: Need BiDi support. int layoutFlags = Font.LAYOUT_LEFT_TO_RIGHT @@ -316,7 +330,7 @@ | Font.LAYOUT_NO_LIMIT_CONTEXT; gv = style.getFont().layoutGlyphVector( fontRenderContext, - seg.array, textStart, textLimit, layoutFlags); + textArray, textStart, textLimit, layoutFlags); Rectangle2D logicalBounds = gv.getLogicalBounds(); width = (float)logicalBounds.getWidth(); @@ -325,5 +339,22 @@ //{{{ Private members private float[] positions; + + // Flag to enable a workaround for a bug in Sun Java 5. + private static final boolean SUN_JAVA_5; + static + { + boolean sun_java_5 = false; + String vendor = System.getProperty("java.vendor"); + if (vendor != null && vendor.startsWith("Sun")) + { + String version = System.getProperty("java.version"); + if (version != null && version.startsWith("1.5")) + { + sun_java_5 = true; + } + } + SUN_JAVA_5 = sun_java_5; + } //}}} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |