Skip to content

Commit

Permalink
ICU4J changes
Browse files Browse the repository at this point in the history
  • Loading branch information
naotoj committed Sep 17, 2024
1 parent a2e4bb0 commit 3b7dc51
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 86 deletions.
178 changes: 108 additions & 70 deletions src/java.base/share/classes/jdk/internal/icu/impl/NormalizerImpl.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -40,6 +40,7 @@
import jdk.internal.icu.lang.UCharacter.NumericType;
import jdk.internal.icu.text.UTF16;
import jdk.internal.icu.text.UnicodeSet;
import jdk.internal.icu.util.CodePointTrie;
import jdk.internal.icu.util.VersionInfo;

/**
Expand Down Expand Up @@ -136,10 +137,8 @@ public int getAdditional(int codepoint, int column) {
*/
public VersionInfo getAge(int codepoint)
{
int version = getAdditional(codepoint, 0) >> AGE_SHIFT_;
return VersionInfo.getInstance(
(version >> FIRST_NIBBLE_SHIFT_) & LAST_NIBBLE_MASK_,
version & LAST_NIBBLE_MASK_, 0, 0);
int version = getAdditional(codepoint, 0) >>> AGE_SHIFT_;
return VersionInfo.getInstance(version >> 2, version & 3, 0, 0);
}

// int-value and enumerated properties --------------------------------- ***
Expand All @@ -151,6 +150,10 @@ public int getType(int c) {
/*
* Map some of the Grapheme Cluster Break values to Hangul Syllable Types.
* Hangul_Syllable_Type is fully redundant with a subset of Grapheme_Cluster_Break.
*
* Starting with Unicode 16, there is an exception:
* Some Kirat Rai vowels are given GCB=V for proper grapheme clustering, but
* they are of course not related to Hangul syllables.
*/
private static final int /* UHangulSyllableType */ gcbToHst[]={
HangulSyllableType.NOT_APPLICABLE, /* U_GCB_OTHER */
Expand Down Expand Up @@ -310,11 +313,16 @@ public int digit(int c) {
* 0
*/
int m_maxJTGValue_;
/** maximum values for other code values */
int m_maxValuesOther_;

/**
* Script_Extensions data
*/
public char[] m_scriptExtensions_;

CodePointTrie m_blockTrie_;

// private variables -------------------------------------------------

/**
Expand Down Expand Up @@ -534,12 +542,13 @@ private UCharacterProperty() throws IOException
int additionalVectorsOffset = bytes.getInt();
m_additionalColumnsCount_ = bytes.getInt();
int scriptExtensionsOffset = bytes.getInt();
int reservedOffset7 = bytes.getInt();
/* reservedOffset8 = */ bytes.getInt();
int blockTrieOffset = bytes.getInt();
int reservedOffset8 = bytes.getInt();
/* dataTopOffset = */ bytes.getInt();
m_maxBlockScriptValue_ = bytes.getInt();
m_maxJTGValue_ = bytes.getInt();
ICUBinary.skipBytes(bytes, (16 - 12) << 2);
m_maxValuesOther_ = bytes.getInt();
ICUBinary.skipBytes(bytes, (16 - 13) << 2);

// read the main properties trie
m_trie_ = Trie2_16.createFromSerialized(bytes);
Expand Down Expand Up @@ -574,19 +583,29 @@ private UCharacterProperty() throws IOException
}

// Script_Extensions
int numChars = (reservedOffset7 - scriptExtensionsOffset) * 2;
int numChars = (blockTrieOffset - scriptExtensionsOffset) * 2;
if(numChars > 0) {
m_scriptExtensions_ = new char[numChars];
for(int i = 0; i < numChars; ++i) {
m_scriptExtensions_[i] = bytes.getChar();
}
}

// Read the blockTrie.
int partLength = (reservedOffset8 - blockTrieOffset) * 4;
int triePosition = bytes.position();
m_blockTrie_ = CodePointTrie.fromBinary(null, CodePointTrie.ValueWidth.BITS_16, bytes);
trieLength = bytes.position() - triePosition;
if (trieLength > partLength) {
throw new IOException("uprops.icu: not enough bytes for blockTrie");
}
ICUBinary.skipBytes(bytes, partLength - trieLength); // skip padding after trie bytes
}

private static final class IsAcceptable implements ICUBinary.Authenticate {
// @Override when we switch to Java 6
public boolean isDataVersionAcceptable(byte version[]) {
return version[0] == 7;
return version[0] == 9;
}
}

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,7 +36,7 @@

package jdk.internal.icu.util;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
* Class to store version numbers of the form major.minor.milli.micro.
Expand All @@ -48,13 +48,13 @@ public final class VersionInfo
// public data members -------------------------------------------------

/**
* Data version string for ICU's internal data.
* Used for appending to data path (e.g. icudt43b)
* Data version string for ICU's data file.
* Not used when loading from resources packaged in the .jar.
* @internal
* @deprecated This API is ICU internal only.
*/
@Deprecated
public static final String ICU_DATA_VERSION_PATH = "74b";
public static final String ICU_DATA_VERSION_PATH = "76b";

// public methods ------------------------------------------------------

Expand Down Expand Up @@ -171,7 +171,7 @@ public int compareTo(VersionInfo other)
/**
* Map of singletons
*/
private static final HashMap<Integer, Object> MAP_ = new HashMap<>();
private static final ConcurrentHashMap<Integer, Object> MAP_ = new ConcurrentHashMap<>();
/**
* Error statement string
*/
Expand Down

0 comments on commit 3b7dc51

Please sign in to comment.