Internal Error in Collator.getInstance with Eclipse and Java 6

Description

see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=134689 and
https://bugs.eclipse.org/bugs/show_bug.cgi?id=134842

Right clicking a project in Eclipse (3.2 M6) results in a Internal Error.
Maybe this is also related to jdk 6.0.

java.lang.InternalError: Can't map string pool offset 20273 to index
at
com.ibm.icu.impl.UPropertyAliases$Builder.stringOffsetToIndex(UPropertyAliases.java:588)
at
com.ibm.icu.impl.UPropertyAliases$Builder.access$1(UPropertyAliases.java:580)
at
com.ibm.icu.impl.UPropertyAliases$NameToEnum.<init>(UPropertyAliases.java:378)
at com.ibm.icu.impl.UPropertyAliases.<init>(UPropertyAliases.java:186)
at com.ibm.icu.lang.UCharacter.<clinit>(UCharacter.java:5680)
at com.ibm.icu.text.CollatorReader.<init>(CollatorReader.java:120)
at com.ibm.icu.text.CollatorReader.<init>(CollatorReader.java:91)
at com.ibm.icu.text.CollatorReader.read(CollatorReader.java:43)
at
com.ibm.icu.text.RuleBasedCollator.<clinit>(RuleBasedCollator.java:1751)
at
com.ibm.icu.text.CollatorServiceShim$1$CollatorFactory.handleCreate(CollatorServiceShim.java:114)
at
com.ibm.icu.impl.ICULocaleService$LocaleKeyFactory.create(ICULocaleService.java:359)
at com.ibm.icu.impl.ICUService.getKey(ICUService.java:463)
at com.ibm.icu.impl.ICUService.getKey(ICUService.java:383)
at com.ibm.icu.impl.ICULocaleService.get(ICULocaleService.java:72)
at com.ibm.icu.impl.ICULocaleService.get(ICULocaleService.java:56)
at
com.ibm.icu.text.CollatorServiceShim.getInstance(CollatorServiceShim.java:34)
at com.ibm.icu.text.Collator.getInstance(Collator.java:484)
at com.ibm.icu.text.Collator.getInstance(Collator.java:315)
at
org.eclipse.jdt.internal.ui.search.WorkingSetsComparator.<init>(WorkingSetsComparator.java:19)
at
org.eclipse.jdt.internal.ui.search.LRUWorkingSetsList.<init>(LRUWorkingSetsList.java:26)
at
org.eclipse.jdt.internal.ui.search.SearchUtil.restoreState(SearchUtil.java:156)
at
org.eclipse.jdt.internal.ui.search.SearchUtil.getLRUWorkingSets(SearchUtil.java:150)
at
org.eclipse.jdt.ui.actions.ReferencesSearchGroup.fillContextMenu(ReferencesSearchGroup.java:174)
at
org.eclipse.jdt.ui.actions.JavaSearchActionGroup.fillContextMenu(JavaSearchActionGroup.java:133)
at
org.eclipse.jdt.internal.ui.actions.CompositeActionGroup.fillContextMenu(CompositeActionGroup.java:77)
at
org.eclipse.jdt.internal.ui.browsing.JavaBrowsingPart.menuAboutToShow(JavaBrowsingPart.java:542)
at
org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:289)

Activity

Show:
TracBot
June 30, 2018, 11:33 PM
Trac Comment by auditor—1970-01-01T01:25:40.000Z
  • Sat Apr 8 09:23:42 2006 dougfelt changed notes2: assign: "" to "ram", priority: "" to "high", summmary: "" to "Internal Error in Collator.getInstance with Eclipse and Java 6", target: "UNSCH" to "3.6",

  • Sat Apr 8 09:23:42 2006 dougfelt moved from incoming to others

  • Tue Apr 18 09:30:37 2006 dougfelt sent reply 1

  • Tue Apr 18 09:31:13 2006 dougfelt changed notes2: assign: "ram" to "doug", target: "3.6" to "3.5",

  • Fri May 5 11:42:07 2006 dougfelt changed notes2: review: "" to "ram", comments: "" to "difficult to test, but problem is obvious and fix is simple. so no test changes for this.",

  • Tue Jul 25 14:14:47 2006 guest sent reply 2

  • Mon Aug 7 15:36:13 2006 ram moved from others to fixed

  • Sun Oct 22 07:39:04 2006 grhoten moved from fixed to closed

TracBot
June 30, 2018, 11:33 PM
Trac Comment by Doug Felt <doug.felt@c66d9d543b9863e0—2006-04-18T16:30:37.000Z

comment from Oliver Thomann:

Here is the cause of the problem. All line numbers are given according to the source of ICU 3.4.4.

Test case to reproduce the issue:
public class X {

public static void main(String[] args) {
System.out.println(com.ibm.icu.text.Collator.getInstance());
}
}

Using JDK6.0b77, the following code works fine.
Using JDK6.0b78, it fails with:

Exception in thread "main" java.lang.InternalError: Can't map string pool offset 20273 to index
at com.ibm.icu.impl.UPropertyAliases$Builder.stringOffsetToIndex(UPropertyAliases.java:588)
at com.ibm.icu.impl.UPropertyAliases$Builder.access$1(UPropertyAliases.java:580)
at com.ibm.icu.impl.UPropertyAliases$NameToEnum.<init>(UPropertyAliases.java:378)
at com.ibm.icu.impl.UPropertyAliases.<init>(UPropertyAliases.java:186)
at com.ibm.icu.lang.UCharacter.<clinit>(UCharacter.java:5680)
at com.ibm.icu.text.CollatorReader.<init>(CollatorReader.java:120)
at com.ibm.icu.text.CollatorReader.<init>(CollatorReader.java:91)
at com.ibm.icu.text.CollatorReader.read(CollatorReader.java:43)
at com.ibm.icu.text.RuleBasedCollator.<clinit>(RuleBasedCollator.java:1751)
at com.ibm.icu.text.CollatorServiceShim$1$CollatorFactory.handleCreate(CollatorServiceShim.java:114)
at com.ibm.icu.impl.ICULocaleService$LocaleKeyFactory.create(ICULocaleService.java:359)
at com.ibm.icu.impl.ICUService.getKey(ICUService.java:463)
at com.ibm.icu.impl.ICUService.getKey(ICUService.java:383)
at com.ibm.icu.impl.ICULocaleService.get(ICULocaleService.java:72)
at com.ibm.icu.impl.ICULocaleService.get(ICULocaleService.java:56)
at com.ibm.icu.text.CollatorServiceShim.getInstance(CollatorServiceShim.java:34)
at com.ibm.icu.text.Collator.getInstance(Collator.java:484)
at com.ibm.icu.text.Collator.getInstance(Collator.java:315)
at X.main(X.java:4)

Line 163 of com.ibm.icu.impl.UPropertyAliases is the cause of the problem.
The d.read(raw) doesn't garantee that the whole byte array is filled.

If I replace that line with:

System.out.println("Total size = " + total_size);
System.out.println(d.read(raw));

it prints:
JDK6.0b77:
Total size = 20554
20554

JDK6.0b78
Total size = 20554
8192

JDK1.5.0_06
Total size = 20554
20554

So using the JDK6.0b78, only a subpart of the raw array is initialized. In order to make sure that the whole array is initialized. The code needs to loop over the read.
Replacing:

d.read(raw);
with:
d.readFully(raw);

will initialize the whole array and it doesn't fail anymore. readFully(byte[]) seems to do what needs to be done.
See http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataInput.html#readFully(byte[])

The fact that it works with the JDK1.5.0_06 or 6.0b77 doesn't mean that other implementations of the libraries might work. Other platforms like Mac might read streams differently than Windows.

So hopefully the description of the problem is clear enough so that the patch can be applied and released.
Let me know if you have any questions.

Olivier Thomann

TracBot
June 30, 2018, 11:33 PM
Trac Comment by Ben Konrath <bkonrath@e301bebf79920c93—2006-07-25T21:14:47.000Z

(Guest Reply)

Where did this fix end up? Has it been committed to cvs somewhere? Or is there somewhere else I should look for this fix? Thanks.

TracBot
June 30, 2018, 11:33 PM
Trac Comment 4.5 by —2015-02-04T18:13:39.810Z

Replying to (Comment 4 Ben Konrath <bkonrath(at)redhat.com>):

(Guest Reply)

 

Where did this fix end up? Has it been committed to cvs somewhere? Or is there somewhere else I should look for this fix? Thanks.

For the record: fixed in ICU4J 3.5

TracBot
June 30, 2018, 11:33 PM
Trac Comment 6 by —2016-10-05T23:18:25.123Z

Milestone 3.5 deleted

Fixed

Assignee

Douglas Felt

Reporter

TracBot

Components

Labels

None

Reviewer

None

Priority

major

Time Needed

None

Fix versions