1 /* 2 * Copyright (C) 2015 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.icu4j.srcgen; 17 18 import static com.google.currysrc.api.process.Rules.createMandatoryRule; 19 import static com.google.currysrc.api.process.Rules.createOptionalRule; 20 21 import org.eclipse.jdt.core.JavaCore; 22 import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; 23 24 import com.google.common.collect.Lists; 25 import com.google.currysrc.Main; 26 import com.google.currysrc.aosp.Annotations; 27 import com.google.currysrc.api.RuleSet; 28 import com.google.currysrc.api.input.InputFileGenerator; 29 import com.google.currysrc.api.output.BasicOutputSourceFileGenerator; 30 import com.google.currysrc.api.output.OutputSourceFileGenerator; 31 import com.google.currysrc.api.process.Rule; 32 import com.google.currysrc.api.process.ast.BodyDeclarationLocator; 33 import com.google.currysrc.api.process.ast.BodyDeclarationLocators; 34 import com.google.currysrc.api.process.ast.TypeLocator; 35 import com.google.currysrc.processors.AddAnnotation; 36 import com.google.currysrc.processors.AddDefaultConstructor; 37 import com.google.currysrc.processors.HidePublicClasses; 38 import com.google.currysrc.processors.InsertHeader; 39 import com.google.currysrc.processors.ModifyQualifiedNames; 40 import com.google.currysrc.processors.ModifyStringLiterals; 41 import com.google.currysrc.processors.RemoveJavaDocTags; 42 import com.google.currysrc.processors.RenamePackage; 43 import com.google.currysrc.processors.ReplaceTextCommentScanner; 44 45 import java.io.File; 46 import java.nio.file.Path; 47 import java.nio.file.Paths; 48 import java.util.Arrays; 49 import java.util.List; 50 import java.util.Map; 51 import java.util.stream.Collectors; 52 53 /** 54 * Applies Android's ICU4J source code transformation rules. If you make any changes to this class 55 * then you should re-run the generate_android_icu4j.sh script. 56 */ 57 public class Icu4jTransform { 58 59 // The list of public ICU API classes exposed on Android. If you change this, you should change 60 // the INITIAL_DEPRECATED_SET below to include entries from the new classes. 61 static final String[] PUBLIC_API_CLASSES = new String[] { 62 /* ASCII order please. */ 63 "android.icu.lang.UCharacter", 64 "android.icu.lang.UCharacter$BidiPairedBracketType", 65 "android.icu.lang.UCharacter$DecompositionType", 66 "android.icu.lang.UCharacter$EastAsianWidth", 67 "android.icu.lang.UCharacter$GraphemeClusterBreak", 68 "android.icu.lang.UCharacter$HangulSyllableType", 69 "android.icu.lang.UCharacter$IndicPositionalCategory", 70 "android.icu.lang.UCharacter$IndicSyllabicCategory", 71 "android.icu.lang.UCharacter$JoiningGroup", 72 "android.icu.lang.UCharacter$JoiningType", 73 "android.icu.lang.UCharacter$LineBreak", 74 "android.icu.lang.UCharacter$NumericType", 75 "android.icu.lang.UCharacter$SentenceBreak", 76 "android.icu.lang.UCharacter$UnicodeBlock", 77 "android.icu.lang.UCharacter$VerticalOrientation", 78 "android.icu.lang.UCharacter$WordBreak", 79 "android.icu.lang.UCharacterCategory", 80 "android.icu.lang.UCharacterDirection", 81 "android.icu.lang.UCharacterEnums", 82 "android.icu.lang.UCharacterEnums$ECharacterCategory", 83 "android.icu.lang.UCharacterEnums$ECharacterDirection", 84 "android.icu.lang.UProperty", 85 "android.icu.lang.UProperty$NameChoice", 86 "android.icu.lang.UScript", 87 "android.icu.lang.UScript$ScriptUsage", 88 "android.icu.math.BigDecimal", 89 "android.icu.math.MathContext", 90 "android.icu.number.CompactNotation", 91 "android.icu.number.CurrencyPrecision", 92 "android.icu.number.FormattedNumber", 93 "android.icu.number.FormattedNumberRange", 94 "android.icu.number.FractionPrecision", 95 "android.icu.number.IntegerWidth", 96 "android.icu.number.LocalizedNumberFormatter", 97 "android.icu.number.LocalizedNumberRangeFormatter", 98 "android.icu.number.Notation", 99 "android.icu.number.NumberFormatter", 100 "android.icu.number.NumberFormatter$DecimalSeparatorDisplay", 101 "android.icu.number.NumberFormatter$GroupingStrategy", 102 "android.icu.number.NumberFormatter$SignDisplay", 103 "android.icu.number.NumberFormatter$UnitWidth", 104 "android.icu.number.NumberFormatterSettings", 105 "android.icu.number.NumberRangeFormatter", 106 "android.icu.number.NumberRangeFormatter$RangeCollapse", 107 "android.icu.number.NumberRangeFormatter$RangeIdentityFallback", 108 "android.icu.number.NumberRangeFormatter$RangeIdentityResult", 109 "android.icu.number.NumberRangeFormatterSettings", 110 "android.icu.number.Precision", 111 "android.icu.number.Scale", 112 "android.icu.number.ScientificNotation", 113 "android.icu.number.SimpleNotation", 114 "android.icu.number.UnlocalizedNumberFormatter", 115 "android.icu.number.UnlocalizedNumberRangeFormatter", 116 "android.icu.text.AlphabeticIndex", 117 "android.icu.text.AlphabeticIndex$Bucket", 118 "android.icu.text.AlphabeticIndex$Bucket$LabelType", 119 "android.icu.text.AlphabeticIndex$ImmutableIndex", 120 "android.icu.text.AlphabeticIndex$Record", 121 "android.icu.text.Bidi", 122 "android.icu.text.BidiClassifier", 123 "android.icu.text.BidiRun", 124 "android.icu.text.BreakIterator", 125 "android.icu.text.CaseMap", 126 "android.icu.text.CaseMap$Fold", 127 "android.icu.text.CaseMap$Lower", 128 "android.icu.text.CaseMap$Title", 129 "android.icu.text.CaseMap$Upper", 130 "android.icu.text.CollationElementIterator", 131 "android.icu.text.CollationKey", 132 "android.icu.text.CollationKey$BoundMode", 133 "android.icu.text.Collator", 134 "android.icu.text.Collator$CollatorFactory", 135 "android.icu.text.Collator$ReorderCodes", 136 "android.icu.text.CompactDecimalFormat", 137 "android.icu.text.CompactDecimalFormat$CompactStyle", 138 "android.icu.text.ConstrainedFieldPosition", 139 "android.icu.text.CurrencyPluralInfo", 140 "android.icu.text.DateFormat", 141 "android.icu.text.DateFormat$BooleanAttribute", 142 "android.icu.text.DateFormat$Field", 143 "android.icu.text.DateFormatSymbols", 144 "android.icu.text.DateIntervalFormat", 145 "android.icu.text.DateIntervalFormat$FormattedDateInterval", 146 "android.icu.text.DateIntervalInfo", 147 "android.icu.text.DateIntervalInfo$PatternInfo", 148 "android.icu.text.DateTimePatternGenerator", 149 "android.icu.text.DateTimePatternGenerator$DisplayWidth", 150 "android.icu.text.DateTimePatternGenerator$PatternInfo", 151 "android.icu.text.DecimalFormat", 152 "android.icu.text.DecimalFormatSymbols", 153 "android.icu.text.DisplayContext", 154 "android.icu.text.DisplayContext$Type", 155 "android.icu.text.Edits", 156 "android.icu.text.Edits$Iterator", 157 "android.icu.text.FormattedValue", 158 "android.icu.text.IDNA", 159 "android.icu.text.IDNA$Error", 160 "android.icu.text.IDNA$Info", 161 "android.icu.text.ListFormatter", 162 "android.icu.text.LocaleDisplayNames", 163 "android.icu.text.LocaleDisplayNames$DialectHandling", 164 "android.icu.text.LocaleDisplayNames$UiListItem", 165 "android.icu.text.MeasureFormat", 166 "android.icu.text.MeasureFormat$FormatWidth", 167 "android.icu.text.MessageFormat", 168 "android.icu.text.MessageFormat$Field", 169 "android.icu.text.MessagePattern", 170 "android.icu.text.MessagePattern$ApostropheMode", 171 "android.icu.text.MessagePattern$ArgType", 172 "android.icu.text.MessagePattern$Part", 173 "android.icu.text.MessagePattern$Part$Type", 174 "android.icu.text.Normalizer", 175 "android.icu.text.Normalizer$QuickCheckResult", 176 "android.icu.text.Normalizer2", 177 "android.icu.text.Normalizer2$Mode", 178 "android.icu.text.NumberFormat", 179 "android.icu.text.NumberFormat$Field", 180 "android.icu.text.NumberingSystem", 181 "android.icu.text.PluralFormat", 182 "android.icu.text.PluralRules", 183 "android.icu.text.PluralRules$PluralType", 184 "android.icu.text.RelativeDateTimeFormatter", 185 "android.icu.text.RelativeDateTimeFormatter$AbsoluteUnit", 186 "android.icu.text.RelativeDateTimeFormatter$Direction", 187 "android.icu.text.RelativeDateTimeFormatter$FormattedRelativeDateTime", 188 "android.icu.text.RelativeDateTimeFormatter$RelativeDateTimeUnit", 189 "android.icu.text.RelativeDateTimeFormatter$RelativeUnit", 190 "android.icu.text.RelativeDateTimeFormatter$Style", 191 "android.icu.text.Replaceable", 192 "android.icu.text.RuleBasedCollator", 193 "android.icu.text.ScientificNumberFormatter", 194 "android.icu.text.SearchIterator", 195 "android.icu.text.SearchIterator$ElementComparisonType", 196 "android.icu.text.SelectFormat", 197 "android.icu.text.SimpleDateFormat", 198 "android.icu.text.StringPrepParseException", 199 "android.icu.text.StringSearch", 200 "android.icu.text.SymbolTable", 201 "android.icu.text.TimeZoneFormat", 202 "android.icu.text.TimeZoneFormat$GMTOffsetPatternType", 203 "android.icu.text.TimeZoneFormat$ParseOption", 204 "android.icu.text.TimeZoneFormat$Style", 205 "android.icu.text.TimeZoneFormat$TimeType", 206 "android.icu.text.TimeZoneNames", 207 "android.icu.text.TimeZoneNames$NameType", 208 "android.icu.text.Transliterator", 209 "android.icu.text.Transliterator$Position", 210 "android.icu.text.UCharacterIterator", 211 "android.icu.text.UFormat", 212 "android.icu.text.UnicodeFilter", 213 "android.icu.text.UnicodeMatcher", 214 "android.icu.text.UnicodeSet", 215 "android.icu.text.UnicodeSet$ComparisonStyle", 216 "android.icu.text.UnicodeSet$EntryRange", 217 "android.icu.text.UnicodeSet$SpanCondition", 218 "android.icu.text.UnicodeSetIterator", 219 "android.icu.text.UnicodeSetSpanner", 220 "android.icu.text.UnicodeSetSpanner$CountMethod", 221 "android.icu.text.UnicodeSetSpanner$TrimOption", 222 "android.icu.util.BuddhistCalendar", 223 "android.icu.util.CECalendar", 224 "android.icu.util.Calendar", 225 "android.icu.util.Calendar$WeekData", 226 "android.icu.util.ChineseCalendar", 227 "android.icu.util.CopticCalendar", 228 "android.icu.util.Currency", 229 "android.icu.util.Currency$CurrencyUsage", 230 "android.icu.util.CurrencyAmount", 231 "android.icu.util.DateInterval", 232 "android.icu.util.EthiopicCalendar", 233 "android.icu.util.Freezable", 234 "android.icu.util.GregorianCalendar", 235 "android.icu.util.HebrewCalendar", 236 "android.icu.util.ICUUncheckedIOException", 237 "android.icu.util.IllformedLocaleException", 238 "android.icu.util.IndianCalendar", 239 "android.icu.util.IslamicCalendar", 240 "android.icu.util.IslamicCalendar$CalculationType", 241 "android.icu.util.JapaneseCalendar", 242 "android.icu.util.LocaleData", 243 "android.icu.util.LocaleData$MeasurementSystem", 244 "android.icu.util.LocaleData$PaperSize", 245 "android.icu.util.Measure", 246 "android.icu.util.MeasureUnit", 247 "android.icu.util.Output", 248 "android.icu.util.RangeValueIterator", 249 "android.icu.util.RangeValueIterator$Element", 250 "android.icu.util.TaiwanCalendar", 251 "android.icu.util.TimeUnit", 252 "android.icu.util.TimeZone", 253 "android.icu.util.TimeZone$SystemTimeZoneType", 254 "android.icu.util.ULocale", 255 "android.icu.util.ULocale$AvailableType", 256 "android.icu.util.ULocale$Builder", 257 "android.icu.util.ULocale$Category", 258 "android.icu.util.UniversalTimeScale", 259 "android.icu.util.ValueIterator", 260 "android.icu.util.ValueIterator$Element", 261 "android.icu.util.VersionInfo", 262 263 }; 264 265 /** 266 * The set of deprecated ICU types/methods/fields that must not be part of the public API as they 267 * were deprecated when Android first exposed their classes as a public API. Methods deprecated by 268 * ICU after this will be visible and deprecated in Android. 269 */ 270 // This list was originally generated by the CaptureDeprecatedElements tool when run against 271 // ICU56 with the original PUBLIC_API_CLASSES. 272 private static final String[] INITIAL_DEPRECATED_SET = new String[] { 273 /* ASCII order please. */ 274 "field:android.icu.lang.UProperty#ISO_COMMENT", 275 "field:android.icu.lang.UProperty#UNDEFINED", 276 "field:android.icu.lang.UProperty#UNICODE_1_NAME", 277 "field:android.icu.lang.UScript#DUPLOYAN_SHORTAND", 278 "field:android.icu.text.Bidi#CLASS_DEFAULT", 279 "field:android.icu.text.CaseMap#internalOptions", 280 "field:android.icu.text.DateFormat#ABBR_STANDALONE_MONTH", 281 "field:android.icu.text.DateFormat#DATE_SKELETONS", 282 "field:android.icu.text.DateFormat#HOUR_GENERIC_TZ", 283 "field:android.icu.text.DateFormat#HOUR_MINUTE_GENERIC_TZ", 284 "field:android.icu.text.DateFormat#HOUR_MINUTE_TZ", 285 "field:android.icu.text.DateFormat#HOUR_TZ", 286 "field:android.icu.text.DateFormat#STANDALONE_MONTH", 287 "field:android.icu.text.DateFormat#TIME_SKELETONS", 288 "field:android.icu.text.DateFormat#ZONE_SKELETONS", 289 "field:android.icu.text.DateFormatSymbols#DT_CONTEXT_COUNT", 290 "field:android.icu.text.DateFormatSymbols#DT_WIDTH_COUNT", 291 "field:android.icu.text.DateFormatSymbols#NUMERIC", 292 "field:android.icu.text.DateTimePatternGenerator#MATCH_MINUTE_FIELD_LENGTH", 293 "field:android.icu.text.DateTimePatternGenerator#MATCH_SECOND_FIELD_LENGTH", 294 "field:android.icu.text.IDNA#ALLOW_UNASSIGNED", 295 "field:android.icu.text.Normalizer#COMPARE_NORM_OPTIONS_SHIFT", 296 "field:android.icu.text.Normalizer#COMPOSE", 297 "field:android.icu.text.Normalizer#COMPOSE_COMPAT", 298 "field:android.icu.text.Normalizer#DECOMP", 299 "field:android.icu.text.Normalizer#DECOMP_COMPAT", 300 "field:android.icu.text.Normalizer#DEFAULT", 301 "field:android.icu.text.Normalizer#DONE", 302 "field:android.icu.text.Normalizer#FCD", 303 "field:android.icu.text.Normalizer#IGNORE_HANGUL", 304 "field:android.icu.text.Normalizer#NFC", 305 "field:android.icu.text.Normalizer#NFD", 306 "field:android.icu.text.Normalizer#NFKC", 307 "field:android.icu.text.Normalizer#NFKD", 308 "field:android.icu.text.Normalizer#NONE", 309 "field:android.icu.text.Normalizer#NO_OP", 310 "field:android.icu.text.Normalizer#UNICODE_3_2", 311 "field:android.icu.text.PluralRules#CATEGORY_SEPARATOR", 312 "field:android.icu.text.PluralRules#KEYWORD_RULE_SEPARATOR", 313 "field:android.icu.text.PluralRules$FixedDecimal#decimalDigits", 314 "field:android.icu.text.PluralRules$FixedDecimal#decimalDigitsWithoutTrailingZeros", 315 "field:android.icu.text.PluralRules$FixedDecimal#hasIntegerValue", 316 "field:android.icu.text.PluralRules$FixedDecimal#integerValue", 317 "field:android.icu.text.PluralRules$FixedDecimal#isNegative", 318 "field:android.icu.text.PluralRules$FixedDecimal#source", 319 "field:android.icu.text.PluralRules$FixedDecimal#visibleDecimalDigitCount", 320 "field:android.icu.text.PluralRules$FixedDecimal#visibleDecimalDigitCountWithoutTrailingZeros", 321 "field:android.icu.text.PluralRules$FixedDecimalRange#end", 322 "field:android.icu.text.PluralRules$FixedDecimalRange#start", 323 "field:android.icu.text.PluralRules$FixedDecimalSamples#bounded", 324 "field:android.icu.text.PluralRules$FixedDecimalSamples#sampleType", 325 "field:android.icu.text.PluralRules$FixedDecimalSamples#samples", 326 "field:android.icu.text.PluralRules$StandardPluralCategories#COUNT", 327 "field:android.icu.text.PluralRules$StandardPluralCategories#VALUES", 328 "field:android.icu.text.UnicodeSetIterator#endElement", 329 "field:android.icu.text.UnicodeSetIterator#nextElement", 330 "field:android.icu.util.Calendar#WEEKDAY", 331 "field:android.icu.util.Calendar#WEEKEND", 332 "field:android.icu.util.Calendar#WEEKEND_CEASE", 333 "field:android.icu.util.Calendar#WEEKEND_ONSET", 334 "field:android.icu.util.LocaleData#DELIMITER_COUNT", 335 "field:android.icu.util.LocaleData#ES_COUNT", 336 "field:android.icu.util.LocaleData#ES_CURRENCY", 337 "field:android.icu.util.MeasureUnit#subType", 338 "field:android.icu.util.MeasureUnit#type", 339 "field:android.icu.util.VersionInfo#ICU_DATA_VERSION", 340 "field:android.icu.util.VersionInfo#ICU_DATA_VERSION_PATH", 341 "field:android.icu.util.VersionInfo#UCOL_TAILORINGS_VERSION", 342 "method:android.icu.lang.UCharacter#getCharFromName1_0(String)", 343 "method:android.icu.lang.UCharacter#getISOComment(int)", 344 "method:android.icu.lang.UCharacter#getName1_0(int)", 345 "method:android.icu.lang.UCharacter#getName1_0Iterator()", 346 "method:android.icu.lang.UCharacter#getPropertyValueEnumNoThrow(int,CharSequence)", 347 "method:android.icu.lang.UCharacter#getStringPropertyValue(int,int,int)", 348 "method:android.icu.lang.UCharacter#isJavaLetter(int)", 349 "method:android.icu.lang.UCharacter#isJavaLetterOrDigit(int)", 350 "method:android.icu.lang.UCharacter#isSpace(int)", 351 "method:android.icu.lang.UCharacter#toTitleFirst(ULocale,String)", 352 "method:android.icu.text.AlphabeticIndex#getFirstCharactersInScripts()", 353 "method:android.icu.text.BreakIterator#getBreakInstance(ULocale,int)", 354 "method:android.icu.text.CollationElementIterator#getRuleBasedCollator()", 355 "method:android.icu.text.CollationElementIterator#hashCode()", 356 "method:android.icu.text.Collator#doCompare(CharSequence,CharSequence)", 357 "method:android.icu.text.Collator#setStrength2(int)", 358 "method:android.icu.text.Collator#setVariableTop(String)", 359 "method:android.icu.text.Collator#setVariableTop(int)", 360 "method:android.icu.text.CompactDecimalFormat#CompactDecimalFormat(String,DecimalFormatSymbols,CompactStyle,PluralRules,long[],Map<String,String[][]>,Map<String,String[]>,Collection<String>)", 361 "method:android.icu.text.CurrencyPluralInfo#hashCode()", 362 "method:android.icu.text.DateFormatSymbols#getDateFormatBundle(Calendar,Locale)", 363 "method:android.icu.text.DateFormatSymbols#getDateFormatBundle(Calendar,ULocale)", 364 "method:android.icu.text.DateFormatSymbols#getDateFormatBundle(Class<? extends Calendar>,Locale)", 365 "method:android.icu.text.DateFormatSymbols#getDateFormatBundle(Class<? extends Calendar>,ULocale)", 366 "method:android.icu.text.DateFormatSymbols#getLeapMonthPattern(int,int)", 367 "method:android.icu.text.DateFormatSymbols#initializeData(ULocale,CalendarData)", 368 "method:android.icu.text.DateFormatSymbols#setLeapMonthPattern(String,int,int)", 369 "method:android.icu.text.DateIntervalFormat#DateIntervalFormat(String,DateIntervalInfo,SimpleDateFormat)", 370 "method:android.icu.text.DateIntervalFormat#getPatterns(Calendar,Calendar,Output<String>)", 371 "method:android.icu.text.DateIntervalFormat#getRawPatterns()", 372 "method:android.icu.text.DateIntervalFormat#parseObject(String,ParsePosition)", 373 "method:android.icu.text.DateIntervalInfo#DateIntervalInfo()", 374 "method:android.icu.text.DateIntervalInfo#genPatternInfo(String,boolean)", 375 "method:android.icu.text.DateIntervalInfo#getPatterns()", 376 "method:android.icu.text.DateIntervalInfo#getRawPatterns()", 377 "method:android.icu.text.DateTimePatternGenerator#addPatternWithSkeleton(String,String,boolean,PatternInfo)", 378 "method:android.icu.text.DateTimePatternGenerator#getAppendFormatNumber(String)", 379 "method:android.icu.text.DateTimePatternGenerator#getCanonicalSkeletonAllowingDuplicates(String)", 380 "method:android.icu.text.DateTimePatternGenerator#getDefaultHourFormatChar()", 381 "method:android.icu.text.DateTimePatternGenerator#getFields(String)", 382 "method:android.icu.text.DateTimePatternGenerator#getFrozenInstance(ULocale)", 383 "method:android.icu.text.DateTimePatternGenerator#getRedundants(Collection<String>)", 384 "method:android.icu.text.DateTimePatternGenerator#getSkeletonAllowingDuplicates(String)", 385 "method:android.icu.text.DateTimePatternGenerator#isSingleField(String)", 386 "method:android.icu.text.DateTimePatternGenerator#setDefaultHourFormatChar(char)", 387 "method:android.icu.text.DateTimePatternGenerator#skeletonsAreSimilar(String,String)", 388 "method:android.icu.text.DateTimePatternGenerator$FormatParser#FormatParser()", 389 "method:android.icu.text.DateTimePatternGenerator$FormatParser#getItems()", 390 "method:android.icu.text.DateTimePatternGenerator$FormatParser#hasDateAndTimeFields()", 391 "method:android.icu.text.DateTimePatternGenerator$FormatParser#quoteLiteral(String)", 392 "method:android.icu.text.DateTimePatternGenerator$FormatParser#set(String)", 393 "method:android.icu.text.DateTimePatternGenerator$FormatParser#set(String,boolean)", 394 "method:android.icu.text.DateTimePatternGenerator$FormatParser#toString()", 395 "method:android.icu.text.DateTimePatternGenerator$FormatParser#toString(int,int)", 396 "method:android.icu.text.DateTimePatternGenerator$VariableField#VariableField(String)", 397 "method:android.icu.text.DateTimePatternGenerator$VariableField#VariableField(String,boolean)", 398 "method:android.icu.text.DateTimePatternGenerator$VariableField#getCanonicalCode(int)", 399 "method:android.icu.text.DateTimePatternGenerator$VariableField#getType()", 400 "method:android.icu.text.DateTimePatternGenerator$VariableField#isNumeric()", 401 "method:android.icu.text.DateTimePatternGenerator$VariableField#toString()", 402 "method:android.icu.text.DecimalFormat#getEffectiveCurrency()", 403 "method:android.icu.text.DecimalFormatSymbols#getMinusString()", 404 "method:android.icu.text.DecimalFormatSymbols#getPlusString()", 405 "method:android.icu.text.IDNA#IDNA()", 406 "method:android.icu.text.IDNA#addError(Info,Error)", 407 "method:android.icu.text.IDNA#addLabelError(Info,Error)", 408 "method:android.icu.text.IDNA#compare(String,String,int)", 409 "method:android.icu.text.IDNA#compare(StringBuffer,StringBuffer,int)", 410 "method:android.icu.text.IDNA#compare(UCharacterIterator,UCharacterIterator,int)", 411 "method:android.icu.text.IDNA#convertIDNToASCII(String,int)", 412 "method:android.icu.text.IDNA#convertIDNToASCII(StringBuffer,int)", 413 "method:android.icu.text.IDNA#convertIDNToASCII(UCharacterIterator,int)", 414 "method:android.icu.text.IDNA#convertIDNToUnicode(String,int)", 415 "method:android.icu.text.IDNA#convertIDNToUnicode(StringBuffer,int)", 416 "method:android.icu.text.IDNA#convertIDNToUnicode(UCharacterIterator,int)", 417 "method:android.icu.text.IDNA#convertToASCII(String,int)", 418 "method:android.icu.text.IDNA#convertToASCII(StringBuffer,int)", 419 "method:android.icu.text.IDNA#convertToASCII(UCharacterIterator,int)", 420 "method:android.icu.text.IDNA#convertToUnicode(String,int)", 421 "method:android.icu.text.IDNA#convertToUnicode(StringBuffer,int)", 422 "method:android.icu.text.IDNA#convertToUnicode(UCharacterIterator,int)", 423 "method:android.icu.text.IDNA#hasCertainErrors(Info,EnumSet<Error>)", 424 "method:android.icu.text.IDNA#hasCertainLabelErrors(Info,EnumSet<Error>)", 425 "method:android.icu.text.IDNA#isBiDi(Info)", 426 "method:android.icu.text.IDNA#isOkBiDi(Info)", 427 "method:android.icu.text.IDNA#promoteAndResetLabelErrors(Info)", 428 "method:android.icu.text.IDNA#resetInfo(Info)", 429 "method:android.icu.text.IDNA#setBiDi(Info)", 430 "method:android.icu.text.IDNA#setNotOkBiDi(Info)", 431 "method:android.icu.text.IDNA#setTransitionalDifferent(Info)", 432 "method:android.icu.text.LocaleDisplayNames#LocaleDisplayNames()", 433 "method:android.icu.text.LocaleDisplayNames#scriptDisplayNameInContext(String)", 434 "method:android.icu.text.MeasureFormat#formatMeasureRange(Measure,Measure)", 435 "method:android.icu.text.MeasureFormat#getRangeFormat(ULocale,FormatWidth)", 436 "method:android.icu.text.MeasureFormat#getRangePattern(ULocale,FormatWidth)", 437 "method:android.icu.text.Normalizer#Normalizer(CharacterIterator,Mode,int)", 438 "method:android.icu.text.Normalizer#Normalizer(String,Mode,int)", 439 "method:android.icu.text.Normalizer#Normalizer(UCharacterIterator,Mode,int)", 440 "method:android.icu.text.Normalizer#clone()", 441 "method:android.icu.text.Normalizer#compose(String,boolean)", 442 "method:android.icu.text.Normalizer#compose(String,boolean,int)", 443 "method:android.icu.text.Normalizer#compose(char[],char[],boolean,int)", 444 "method:android.icu.text.Normalizer#compose(char[],int,int,char[],int,int,boolean,int)", 445 "method:android.icu.text.Normalizer#concatenate(String,String,Mode,int)", 446 "method:android.icu.text.Normalizer#concatenate(char[],char[],Mode,int)", 447 "method:android.icu.text.Normalizer#concatenate(char[],int,int,char[],int,int,char[],int,int,Normalizer.Mode,int)", 448 "method:android.icu.text.Normalizer#current()", 449 "method:android.icu.text.Normalizer#decompose(String,boolean)", 450 "method:android.icu.text.Normalizer#decompose(String,boolean,int)", 451 "method:android.icu.text.Normalizer#decompose(char[],char[],boolean,int)", 452 "method:android.icu.text.Normalizer#decompose(char[],int,int,char[],int,int,boolean,int)", 453 "method:android.icu.text.Normalizer#endIndex()", 454 "method:android.icu.text.Normalizer#first()", 455 "method:android.icu.text.Normalizer#getBeginIndex()", 456 "method:android.icu.text.Normalizer#getEndIndex()", 457 "method:android.icu.text.Normalizer#getFC_NFKC_Closure(int)", 458 "method:android.icu.text.Normalizer#getFC_NFKC_Closure(int,char[])", 459 "method:android.icu.text.Normalizer#getIndex()", 460 "method:android.icu.text.Normalizer#getLength()", 461 "method:android.icu.text.Normalizer#getMode()", 462 "method:android.icu.text.Normalizer#getOption(int)", 463 "method:android.icu.text.Normalizer#getText()", 464 "method:android.icu.text.Normalizer#getText(char[])", 465 "method:android.icu.text.Normalizer#isNormalized(String,Mode,int)", 466 "method:android.icu.text.Normalizer#isNormalized(char[],int,int,Mode,int)", 467 "method:android.icu.text.Normalizer#isNormalized(int,Mode,int)", 468 "method:android.icu.text.Normalizer#last()", 469 "method:android.icu.text.Normalizer#next()", 470 "method:android.icu.text.Normalizer#normalize(String,Mode)", 471 "method:android.icu.text.Normalizer#normalize(String,Mode,int)", 472 "method:android.icu.text.Normalizer#normalize(char[],char[],Mode,int)", 473 "method:android.icu.text.Normalizer#normalize(char[],int,int,char[],int,int,Mode,int)", 474 "method:android.icu.text.Normalizer#normalize(int,Mode)", 475 "method:android.icu.text.Normalizer#normalize(int,Mode,int)", 476 "method:android.icu.text.Normalizer#previous()", 477 "method:android.icu.text.Normalizer#quickCheck(String,Mode)", 478 "method:android.icu.text.Normalizer#quickCheck(String,Mode,int)", 479 "method:android.icu.text.Normalizer#quickCheck(char[],Mode,int)", 480 "method:android.icu.text.Normalizer#quickCheck(char[],int,int,Mode,int)", 481 "method:android.icu.text.Normalizer#reset()", 482 "method:android.icu.text.Normalizer#setIndex(int)", 483 "method:android.icu.text.Normalizer#setIndexOnly(int)", 484 "method:android.icu.text.Normalizer#setMode(Mode)", 485 "method:android.icu.text.Normalizer#setOption(int,boolean)", 486 "method:android.icu.text.Normalizer#setText(CharacterIterator)", 487 "method:android.icu.text.Normalizer#setText(String)", 488 "method:android.icu.text.Normalizer#setText(StringBuffer)", 489 "method:android.icu.text.Normalizer#setText(UCharacterIterator)", 490 "method:android.icu.text.Normalizer#setText(char[])", 491 "method:android.icu.text.Normalizer#startIndex()", 492 "method:android.icu.text.Normalizer$Mode#Mode()", 493 "method:android.icu.text.Normalizer$Mode#getNormalizer2(int)", 494 "method:android.icu.text.Normalizer2#Normalizer2()", 495 "method:android.icu.text.NumberFormat#getEffectiveCurrency()", 496 "method:android.icu.text.NumberFormat#getPattern(Locale,int)", 497 "method:android.icu.text.PluralFormat#setLocale(ULocale)", 498 "method:android.icu.text.PluralRules#addSample(String,Number,int,Set<Double>)", 499 "method:android.icu.text.PluralRules#compareTo(PluralRules)", 500 "method:android.icu.text.PluralRules#computeLimited(String,SampleType)", 501 "method:android.icu.text.PluralRules#getAllKeywordValues(String,SampleType)", 502 "method:android.icu.text.PluralRules#getDecimalSamples(String,SampleType)", 503 "method:android.icu.text.PluralRules#getKeywordStatus(String,int,Set<Double>,Output<Double>,SampleType)", 504 "method:android.icu.text.PluralRules#getRules(String)", 505 "method:android.icu.text.PluralRules#getSamples(String,SampleType)", 506 "method:android.icu.text.PluralRules#hashCode()", 507 "method:android.icu.text.PluralRules#isLimited(String)", 508 "method:android.icu.text.PluralRules#isLimited(String,SampleType)", 509 "method:android.icu.text.PluralRules#matches(FixedDecimal,String)", 510 "method:android.icu.text.PluralRules#select(FixedDecimal)", 511 "method:android.icu.text.PluralRules#select(double,int,long)", 512 "method:android.icu.text.PluralRules$Factory#Factory()", 513 "method:android.icu.text.PluralRules$Factory#forLocale(ULocale)", 514 "method:android.icu.text.PluralRules$Factory#forLocale(ULocale,PluralType)", 515 "method:android.icu.text.PluralRules$Factory#getAvailableULocales()", 516 "method:android.icu.text.PluralRules$Factory#getDefaultFactory()", 517 "method:android.icu.text.PluralRules$Factory#getFunctionalEquivalent(ULocale,boolean[])", 518 "method:android.icu.text.PluralRules$Factory#hasOverride(ULocale)", 519 "method:android.icu.text.PluralRules$FixedDecimal#FixedDecimal(String)", 520 "method:android.icu.text.PluralRules$FixedDecimal#FixedDecimal(double)", 521 "method:android.icu.text.PluralRules$FixedDecimal#FixedDecimal(double,int)", 522 "method:android.icu.text.PluralRules$FixedDecimal#FixedDecimal(double,int,long)", 523 "method:android.icu.text.PluralRules$FixedDecimal#FixedDecimal(long)", 524 "method:android.icu.text.PluralRules$FixedDecimal#compareTo(FixedDecimal)", 525 "method:android.icu.text.PluralRules$FixedDecimal#decimals(double)", 526 "method:android.icu.text.PluralRules$FixedDecimal#doubleValue()", 527 "method:android.icu.text.PluralRules$FixedDecimal#equals(Object)", 528 "method:android.icu.text.PluralRules$FixedDecimal#floatValue()", 529 "method:android.icu.text.PluralRules$FixedDecimal#get(Operand)", 530 "method:android.icu.text.PluralRules$FixedDecimal#getBaseFactor()", 531 "method:android.icu.text.PluralRules$FixedDecimal#getDecimalDigits()", 532 "method:android.icu.text.PluralRules$FixedDecimal#getDecimalDigitsWithoutTrailingZeros()", 533 "method:android.icu.text.PluralRules$FixedDecimal#getIntegerValue()", 534 "method:android.icu.text.PluralRules$FixedDecimal#getOperand(String)", 535 "method:android.icu.text.PluralRules$FixedDecimal#getShiftedValue()", 536 "method:android.icu.text.PluralRules$FixedDecimal#getSource()", 537 "method:android.icu.text.PluralRules$FixedDecimal#getVisibleDecimalDigitCount()", 538 "method:android.icu.text.PluralRules$FixedDecimal#getVisibleDecimalDigitCountWithoutTrailingZeros()", 539 "method:android.icu.text.PluralRules$FixedDecimal#hasIntegerValue()", 540 "method:android.icu.text.PluralRules$FixedDecimal#hashCode()", 541 "method:android.icu.text.PluralRules$FixedDecimal#intValue()", 542 "method:android.icu.text.PluralRules$FixedDecimal#isHasIntegerValue()", 543 "method:android.icu.text.PluralRules$FixedDecimal#isNegative()", 544 "method:android.icu.text.PluralRules$FixedDecimal#longValue()", 545 "method:android.icu.text.PluralRules$FixedDecimal#toString()", 546 "method:android.icu.text.PluralRules$FixedDecimalRange#FixedDecimalRange(FixedDecimal,FixedDecimal)", 547 "method:android.icu.text.PluralRules$FixedDecimalRange#toString()", 548 "method:android.icu.text.PluralRules$FixedDecimalSamples#addSamples(Set<Double>)", 549 "method:android.icu.text.PluralRules$FixedDecimalSamples#getSamples()", 550 "method:android.icu.text.PluralRules$FixedDecimalSamples#getStartEndSamples(Set<FixedDecimal>)", 551 "method:android.icu.text.PluralRules$FixedDecimalSamples#toString()", 552 "method:android.icu.text.RuleBasedCollator#doCompare(CharSequence,CharSequence)", 553 "method:android.icu.text.RuleBasedCollator#internalGetCEs(CharSequence)", 554 "method:android.icu.text.RuleBasedCollator#isHiraganaQuaternary()", 555 "method:android.icu.text.RuleBasedCollator#setHiraganaQuaternary(boolean)", 556 "method:android.icu.text.RuleBasedCollator#setHiraganaQuaternaryDefault()", 557 "method:android.icu.text.RuleBasedCollator#setVariableTop(String)", 558 "method:android.icu.text.RuleBasedCollator#setVariableTop(int)", 559 "method:android.icu.text.SearchIterator#setMatchNotFound()", 560 "method:android.icu.text.SimpleDateFormat#SimpleDateFormat(String,DateFormatSymbols,ULocale)", 561 "method:android.icu.text.SimpleDateFormat#getInstance(Calendar.FormatConfiguration)", 562 "method:android.icu.text.SimpleDateFormat#intervalFormatByAlgorithm(Calendar,Calendar,StringBuffer,FieldPosition)", 563 "method:android.icu.text.SimpleDateFormat#subFormat(StringBuffer,char,int,int,int,DisplayContext,FieldPosition,Calendar)", 564 "method:android.icu.text.SimpleDateFormat#subFormat(char,int,int,int,DisplayContext,FieldPosition,Calendar)", 565 "method:android.icu.text.SimpleDateFormat#zeroPaddingNumber(NumberFormat,StringBuffer,int,int,int)", 566 "method:android.icu.text.StringPrepParseException#hashCode()", 567 "method:android.icu.text.StringSearch#setMatchNotFound()", 568 "method:android.icu.text.TimeZoneNames#getDisplayNames(String,NameType[],long,String[],int)", 569 "method:android.icu.text.TimeZoneNames#loadAllDisplayNames()", 570 "method:android.icu.text.TimeZoneNames$Factory#Factory()", 571 "method:android.icu.text.TimeZoneNames$Factory#getTimeZoneNames(ULocale)", 572 "method:android.icu.text.UnicodeFilter#UnicodeFilter()", 573 "method:android.icu.text.UnicodeSet#addBridges(UnicodeSet)", 574 "method:android.icu.text.UnicodeSet#applyPattern(String,ParsePosition,SymbolTable,int)", 575 "method:android.icu.text.UnicodeSet#compare(Iterator<T>,Iterator<T>)", 576 "method:android.icu.text.UnicodeSet#findIn(CharSequence,int,boolean)", 577 "method:android.icu.text.UnicodeSet#findLastIn(CharSequence,int,boolean)", 578 "method:android.icu.text.UnicodeSet#getDefaultXSymbolTable()", 579 "method:android.icu.text.UnicodeSet#getRegexEquivalent()", 580 "method:android.icu.text.UnicodeSet#getSingleCodePoint(CharSequence)", 581 "method:android.icu.text.UnicodeSet#matchesAt(CharSequence,int)", 582 "method:android.icu.text.UnicodeSet#setDefaultXSymbolTable(XSymbolTable)", 583 "method:android.icu.text.UnicodeSet#spanAndCount(CharSequence,int,SpanCondition,OutputInt)", 584 "method:android.icu.text.UnicodeSet#stripFrom(CharSequence,boolean)", 585 "method:android.icu.text.UnicodeSetIterator#getSet()", 586 "method:android.icu.text.UnicodeSetIterator#loadRange(int)", 587 "method:android.icu.text.Transliterator#addSourceTargetSet(UnicodeSet,UnicodeSet,UnicodeSet)", 588 "method:android.icu.text.Transliterator#getFilterAsUnicodeSet(UnicodeSet)", 589 "method:android.icu.text.Transliterator#registerAny()", 590 "method:android.icu.util.Calendar#getDateTimePattern(Calendar,ULocale,int)", 591 "method:android.icu.util.Calendar#getDayOfWeekType(int)", 592 "method:android.icu.util.Calendar#getRelatedYear()", 593 "method:android.icu.util.Calendar#getWeekendTransition(int)", 594 "method:android.icu.util.Calendar#haveDefaultCentury()", 595 "method:android.icu.util.Calendar#setRelatedYear(int)", 596 "method:android.icu.util.Calendar$FormatConfiguration#getCalendar()", 597 "method:android.icu.util.Calendar$FormatConfiguration#getDateFormatSymbols()", 598 "method:android.icu.util.Calendar$FormatConfiguration#getLocale()", 599 "method:android.icu.util.Calendar$FormatConfiguration#getOverrideString()", 600 "method:android.icu.util.Calendar$FormatConfiguration#getPatternString()", 601 "method:android.icu.util.ChineseCalendar#ChineseCalendar(TimeZone,ULocale,int,TimeZone)", 602 "method:android.icu.util.ChineseCalendar#haveDefaultCentury()", 603 "method:android.icu.util.CopticCalendar#getJDEpochOffset()", 604 "method:android.icu.util.CopticCalendar#handleComputeFields(int)", 605 "method:android.icu.util.CopticCalendar#handleGetExtendedYear()", 606 "method:android.icu.util.Currency#parse(ULocale,String,int,ParsePosition)", 607 "method:android.icu.util.HebrewCalendar#isLeapYear(int)", 608 "method:android.icu.util.HebrewCalendar#validateField(int)", 609 "method:android.icu.util.JapaneseCalendar#haveDefaultCentury()", 610 "method:android.icu.util.MeasureUnit#MeasureUnit(String,String)", 611 "method:android.icu.util.MeasureUnit#addUnit(String,String,Factory)", 612 "method:android.icu.util.MeasureUnit#internalGetInstance(String,String)", 613 "method:android.icu.util.MeasureUnit#resolveUnitPerUnit(MeasureUnit,MeasureUnit)", 614 "method:android.icu.util.MeasureUnit$Factory#create(String,String)", 615 "method:android.icu.util.TimeZone#TimeZone(String)", 616 "method:android.icu.util.ULocale#getDisplayScriptInContext()", 617 "method:android.icu.util.ULocale#getDisplayScriptInContext(String,String)", 618 "method:android.icu.util.ULocale#getDisplayScriptInContext(String,ULocale)", 619 "method:android.icu.util.ULocale#getDisplayScriptInContext(ULocale)", 620 "method:android.icu.util.ULocale#minimizeSubtags(ULocale,Minimize)", 621 "method:android.icu.util.VersionInfo#getVersionString(int,int)", 622 "method:android.icu.util.VersionInfo#javaVersion()", 623 "type:android.icu.text.DateTimePatternGenerator$FormatParser", 624 "type:android.icu.text.DateTimePatternGenerator$VariableField", 625 "type:android.icu.text.Normalizer$Mode", 626 "type:android.icu.text.PluralRules$Factory", 627 "type:android.icu.text.PluralRules$FixedDecimal", 628 "type:android.icu.text.PluralRules$FixedDecimalRange", 629 "type:android.icu.text.PluralRules$FixedDecimalSamples", 630 "type:android.icu.text.PluralRules$SampleType", 631 "type:android.icu.text.PluralRules$StandardPluralCategories", 632 "type:android.icu.text.TimeZoneNames$Factory", 633 "type:android.icu.util.Calendar$FormatConfiguration", 634 "type:android.icu.util.MeasureUnit$Factory", 635 "type:android.icu.util.ULocale$Minimize", 636 }; 637 638 /** 639 * A set of declarations we don't want to expose in Android. 640 * We generally hide: 641 * Any API we find that relates to a final static primitive that a compiler could inline 642 * and could change between ICU releases. 643 * Methods that relate to registration of static defaults / factories, which cannot be 644 * configured on Android "before use", because a lot of initialization happens in the zygote. 645 */ 646 private static final String[] DECLARATIONS_TO_HIDE = { 647 /* ASCII order please. */ 648 "field:android.icu.lang.UCharacter$BidiPairedBracketType#COUNT", 649 "field:android.icu.lang.UCharacter$DecompositionType#COUNT", 650 "field:android.icu.lang.UCharacter$EastAsianWidth#COUNT", 651 "field:android.icu.lang.UCharacter$GraphemeClusterBreak#COUNT", 652 "field:android.icu.lang.UCharacter$HangulSyllableType#COUNT", 653 "field:android.icu.lang.UCharacter$JoiningGroup#COUNT", 654 "field:android.icu.lang.UCharacter$JoiningType#COUNT", 655 "field:android.icu.lang.UCharacter$LineBreak#COUNT", 656 "field:android.icu.lang.UCharacter$NumericType#COUNT", 657 "field:android.icu.lang.UCharacter$SentenceBreak#COUNT", 658 "field:android.icu.lang.UCharacter$UnicodeBlock#COUNT", 659 "field:android.icu.lang.UCharacter$WordBreak#COUNT", 660 "field:android.icu.lang.UCharacterEnums$ECharacterCategory#CHAR_CATEGORY_COUNT", 661 "field:android.icu.lang.UCharacterEnums$ECharacterDirection#CHAR_DIRECTION_COUNT", 662 "field:android.icu.lang.UProperty#BINARY_LIMIT", 663 "field:android.icu.lang.UProperty#DOUBLE_LIMIT", 664 "field:android.icu.lang.UProperty#INT_LIMIT", 665 "field:android.icu.lang.UProperty#MASK_LIMIT", 666 "field:android.icu.lang.UProperty#OTHER_PROPERTY_LIMIT", 667 "field:android.icu.lang.UProperty#STRING_LIMIT", 668 "field:android.icu.lang.UProperty$NameChoice#COUNT", 669 "field:android.icu.lang.UScript#CODE_LIMIT", 670 "field:android.icu.text.BidiClassifier#context", 671 "field:android.icu.text.CollationKey$BoundMode#COUNT", 672 "field:android.icu.text.Collator$ReorderCodes#LIMIT", 673 "field:android.icu.text.DateFormat#FIELD_COUNT", 674 "field:android.icu.text.DateTimePatternGenerator#TYPE_LIMIT", 675 "field:android.icu.util.LocaleData#ES_AUXILIARY", 676 "field:android.icu.util.LocaleData#ES_INDEX", 677 "field:android.icu.util.LocaleData#ES_PUNCTUATION", 678 "field:android.icu.util.LocaleData#ES_STANDARD", 679 // Hide new measure units until a clear use case on Android is found. 680 // The cost of these APIs is the storage due to the addtional locale data embedded 681 // in the ICU data file. 682 "field:android.icu.util.MeasureUnit#DUNAM", 683 "field:android.icu.util.MeasureUnit#MOLE", 684 "field:android.icu.util.MeasureUnit#PERMYRIAD", 685 "field:android.icu.util.MeasureUnit#DAY_PERSON", 686 "field:android.icu.util.MeasureUnit#MONTH_PERSON", 687 "field:android.icu.util.MeasureUnit#WEEK_PERSON", 688 "field:android.icu.util.MeasureUnit#YEAR_PERSON", 689 "field:android.icu.util.MeasureUnit#BRITISH_THERMAL_UNIT", 690 "field:android.icu.util.MeasureUnit#ELECTRONVOLT", 691 "field:android.icu.util.MeasureUnit#NEWTON", 692 "field:android.icu.util.MeasureUnit#POUND_FORCE", 693 "field:android.icu.util.MeasureUnit#SOLAR_RADIUS", 694 "field:android.icu.util.MeasureUnit#SOLAR_LUMINOSITY", 695 "field:android.icu.util.MeasureUnit#DALTON", 696 "field:android.icu.util.MeasureUnit#EARTH_MASS", 697 "field:android.icu.util.MeasureUnit#SOLAR_MASS", 698 "field:android.icu.util.MeasureUnit#KILOPASCAL", 699 "field:android.icu.util.MeasureUnit#MEGAPASCAL", 700 "field:android.icu.util.MeasureUnit#NEWTON_METER", 701 "field:android.icu.util.MeasureUnit#POUND_FOOT", 702 "field:android.icu.util.MeasureUnit#BARREL", 703 "field:android.icu.util.MeasureUnit#FLUID_OUNCE_IMPERIAL", 704 "field:android.icu.util.MeasureUnit#BAR", 705 "field:android.icu.util.MeasureUnit#PASCAL", 706 "field:android.icu.util.MeasureUnit#THERM_US", 707 // Skeleton syntax can evolve over time. Currently, the skeleton APIs are not prioritized to 708 // be public. Android developers could easily miss the API version check for new syntax and 709 // cause app crashing on older devices. 710 // See the syntax details in https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md. 711 "method:android.icu.number.NumberFormatterSettings#toSkeleton()", 712 "method:android.icu.number.NumberFormatter#forSkeleton(String)", 713 "method:android.icu.text.BreakIterator#registerInstance(BreakIterator,Locale,int)", 714 "method:android.icu.text.BreakIterator#registerInstance(BreakIterator,ULocale,int)", 715 "method:android.icu.text.BreakIterator#unregister(Object)", 716 "method:android.icu.text.CollationKey#CollationKey(String,RawCollationKey)", 717 "method:android.icu.text.Collator#getRawCollationKey(String,RawCollationKey)", 718 "method:android.icu.text.Collator#registerFactory(CollatorFactory)", 719 "method:android.icu.text.Collator#registerInstance(Collator,ULocale)", 720 "method:android.icu.text.Collator#unregister(Object)", 721 "method:android.icu.text.DecimalFormat#toNumberFormatter()", 722 "method:android.icu.text.DecimalFormatSymbols#getCurrencyPattern()", 723 "method:android.icu.text.NumberFormat#registerFactory(NumberFormatFactory)", 724 "method:android.icu.text.NumberFormat#unregister(Object)", 725 "method:android.icu.text.RuleBasedCollator#getRawCollationKey(String,RawCollationKey)", 726 "method:android.icu.text.UnicodeSet#addAllTo(Iterable<T>,T[])", 727 "method:android.icu.text.UnicodeSet#addAllTo(Iterable<T>,U)", 728 "method:android.icu.text.UnicodeSet#addAllTo(String[])", 729 "method:android.icu.text.UnicodeSet#compare(CharSequence,int)", 730 "method:android.icu.text.UnicodeSet#compare(Collection<T>,Collection<T>,ComparisonStyle)", 731 "method:android.icu.text.UnicodeSet#compare(Iterable<T>,Iterable<T>)", 732 "method:android.icu.text.UnicodeSet#compare(int,CharSequence)", 733 "method:android.icu.text.UnicodeSet#resemblesPattern(String,int)", 734 "method:android.icu.text.UnicodeSet#toArray(UnicodeSet)", 735 "method:android.icu.text.Transliterator#Transliterator(String,UnicodeFilter)", 736 "method:android.icu.text.Transliterator#baseToRules(boolean)", 737 "method:android.icu.text.Transliterator#handleGetSourceSet()", 738 "method:android.icu.text.Transliterator#handleTransliterate(Replaceable,Position,boolean)", 739 "method:android.icu.text.Transliterator#registerAlias(String,String)", 740 "method:android.icu.text.Transliterator#registerClass(String,Class<? extends Transliterator>,String)", 741 "method:android.icu.text.Transliterator#registerFactory(String,Factory)", 742 "method:android.icu.text.Transliterator#registerInstance(Transliterator)", 743 "method:android.icu.text.Transliterator#transform(String)", 744 "method:android.icu.text.Transliterator#unregister(String)", 745 "method:android.icu.text.Transliterator#setID(String)", 746 "method:android.icu.text.Transliterator#setMaximumContextLength(int)", 747 "method:android.icu.util.CECalendar#ceToJD(long,int,int,int)", 748 "method:android.icu.util.CECalendar#getJDEpochOffset()", 749 "method:android.icu.util.CECalendar#jdToCE(int,int,int[])", 750 "method:android.icu.util.Currency#registerInstance(Currency,ULocale)", 751 "method:android.icu.util.Currency#unregister(Object)", 752 "method:android.icu.util.IslamicCalendar#isCivil()", 753 "method:android.icu.util.IslamicCalendar#setCivil(boolean)", 754 "method:android.icu.util.LocaleData#getExemplarSet(int,int)", 755 "method:android.icu.util.LocaleData#getExemplarSet(ULocale,int)", 756 "method:android.icu.util.LocaleData#getExemplarSet(ULocale,int,int)", 757 "method:android.icu.util.LocaleData#getLocaleDisplayPattern()", 758 "method:android.icu.util.LocaleData#getLocaleSeparator()", 759 "method:android.icu.util.TimeZone#clearCachedDefault()", 760 "method:android.icu.util.TimeZone#getDefaultTimeZoneType()", 761 "method:android.icu.util.TimeZone#setDefault(TimeZone)", 762 "method:android.icu.util.TimeZone#setDefaultTimeZoneType(int)", 763 "method:android.icu.util.ULocale#setDefault(Category,ULocale)", 764 "method:android.icu.util.ULocale#setDefault(ULocale)", 765 "method:android.icu.util.VersionInfo#main(String[])", 766 "type:android.icu.text.Collator$CollatorFactory", 767 "type:android.icu.text.NumberFormat$NumberFormatFactory", 768 "type:android.icu.text.NumberFormat$SimpleNumberFormatFactory", 769 }; 770 771 /** 772 * ICU APIs that are in the Android SDK API but are deprecated on Android and not deprecated in 773 * ICU. Entries can be removed if ICU also decide to deprecate. 774 * Entries are usually the result of Android mistakenly exposing an API, an ICU API problem, 775 * and/or ICU's stability guarantees differing from Android's requirements. 776 */ 777 private static final Map<String, String> ANDROID_DEPRECATED_SET = Map.of( 778 /* ASCII order please. */ 779 780 // Unstable "constant" value - different values in different API levels. http://b/77850660. 781 "field:android.icu.util.JapaneseCalendar#CURRENT_ERA", 782 "Use era constants, e.g. {@link #REIWA}, instead.", 783 // The method reads unstable .nrm file format. http://b/173821060 784 "method:android.icu.text.Normalizer2#getInstance(InputStream,String,Mode)", 785 "Don't use because the binary {@code data} format is not stable across API levels." 786 ); 787 788 /** 789 * ICU APIs that are in the Android SDK API but are removed on Android and @stable in ICU. 790 * Entries can be removed if ICU also decide to remove the APIs. 791 * Entries are usually the result of Android mistakenly exposing an API, an ICU API problem, 792 * and/or ICU's stability guarantees differing from Android's requirements. 793 */ 794 private static final String[] ANDROID_REMOVED_SET = { 795 /* ASCII order please. */ 796 // Unstable "constant" value - different values in different API levels. http://b/77850660. 797 "field:android.icu.util.JapaneseCalendar#CURRENT_ERA", 798 }; 799 800 // The declarations with JavaDocs that have @.jcite tags that should be transformed to doclava 801 // @sample tags. Ones not on this list will just be escaped and could show up in the generated 802 // docs. It is assumed that the complete set of ones that should appear in the public API are 803 // listed below and it's ok to escape those that are not. 804 private static final String[] JCITE_TRANSFORM_SET = { 805 "method:android.icu.text.DateIntervalFormat#getInstance(String,Locale)", 806 "method:android.icu.text.DateIntervalFormat#getInstance(String,Locale,DateIntervalInfo)", 807 "method:android.icu.text.DateTimePatternGenerator#addPattern(String,boolean,PatternInfo)", 808 "method:android.icu.text.DateTimePatternGenerator#getBestPattern(String)", 809 "method:android.icu.text.DateTimePatternGenerator#replaceFieldTypes(String,String)", 810 "method:android.icu.text.PluralFormat#PluralFormat(ULocale,String)", 811 }; 812 813 private static final String[] DEFAULT_CONSTRUCTORS = { 814 "android.icu.text.DateTimePatternGenerator$DistanceInfo", 815 "android.icu.text.SpoofChecker$ScriptSet", 816 "android.icu.text.TimeZoneNames$DefaultTimeZoneNames$FactoryImpl", 817 }; 818 819 // Metalava disallows hidden abstract methods in public abstract classes because classes 820 // inheriting such class can cause runtime crashes instead of a compile error. Due to historic 821 // reason, we have such classes in the public SDK. This is the allowlist of hidden abstract 822 // methods, and @SuppressWarnings("HiddenAbstractMethod") annotation will be added into those 823 // methods. See http://b/147445486 for more details. 824 private static final String[] HIDDEN_ABSTRACT_METHODS = { 825 "method:android.icu.text.Collator#getRawCollationKey(String,RawCollationKey)", 826 "method:android.icu.text.Collator#setVariableTop(String)", 827 "method:android.icu.text.Collator#setVariableTop(int)", 828 }; 829 830 public static final String ANDROID_ICU4J_SAMPLE_DIR = 831 "external/icu/android_icu4j/src/samples/java"; 832 833 private static final boolean DEBUG = false; 834 835 static final String ORIGINAL_ICU_PACKAGE = "com.ibm.icu"; 836 static final String ANDROID_ICU_PACKAGE = "android.icu"; 837 Icu4jTransform()838 private Icu4jTransform() { 839 } 840 841 /** 842 * Usage: See {@link Icu4jRules#COMMAND_USAGE} 843 * 844 * The option --hide-non-allowlisted-api can be used to explicitly describe the API surface to be 845 * exposed; anything not in the list will be hidden in additional to other rules. This is useful 846 * when upgrading ICU when we haven't yet added new classes/methods to various hard-coded lists 847 * described below. 848 * 849 * This tool hides the following in the knowledge that classes that are not explicitly 850 * hidden are exposed in the public API set: 851 * 852 * 1) Public classes that are not in the PUBLIC_API_CLASSES list. 853 * 2) Types / fields / methods that were deprecated when the class was first exposed in Android, 854 * listed in INITIAL_DEPRECATED_SET 855 * 3) Types / fields / methods that we explicitly want to hide, listed in DECLARATIONS_TO_HIDE 856 * 4) Types / fields / methods that are flagged with ICU javadoc as draft / provisional or 857 * internal. 858 * 5) If the --hide-non-allowlisted-api option is provided, types / fields / methods that are not 859 * in the allowlisted-api-file. 860 */ main(String[] args)861 public static void main(String[] args) throws Exception { 862 Map<String, String> options = JavaCore.getOptions(); 863 options.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8); 864 options.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8); 865 options.put(JavaCore.COMPILER_DOC_COMMENT_SUPPORT, JavaCore.ENABLED); 866 options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); 867 options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); 868 869 new Main(DEBUG) 870 .setJdtOptions(options) 871 .execute(new Icu4jRules(args)); 872 } 873 874 static class Icu4jRules implements RuleSet { 875 876 private static final String SOURCE_CODE_HEADER = "/* GENERATED SOURCE. DO NOT MODIFY. */\n"; 877 private static final String COMMAND_USAGE = "Usage: " + Icu4jTransform.class.getCanonicalName() 878 + " [--hide-non-allowlisted-api <allowlisted-api-file>]" 879 + " <source-dir>+ <target-dir> <core-platform-api-file> <intra-core-api-file>" 880 + " <unsupported-app-usage-file>"; 881 882 private final InputFileGenerator inputFileGenerator; 883 private final List<Rule> rules; 884 private final BasicOutputSourceFileGenerator outputSourceFileGenerator; 885 Icu4jRules(String[] args)886 public Icu4jRules(String[] args) { 887 if (args.length < 3) { 888 throw new IllegalArgumentException(COMMAND_USAGE); 889 } 890 Path allowlistedApiPath = null; 891 if ("--hide-non-allowlisted-api".equals(args[0])) { 892 allowlistedApiPath = Paths.get(args[1]); 893 if (args.length < 6) { 894 throw new IllegalArgumentException(COMMAND_USAGE); 895 } 896 String[] newArgs = new String[args.length - 2]; 897 System.arraycopy(args, 2, newArgs, 0, args.length - 2); 898 args = newArgs; 899 } 900 901 // Extract the source directories. 902 String[] inputDirNames = new String[args.length - 4]; 903 System.arraycopy(args, 0, inputDirNames, 0, args.length - 4); 904 inputFileGenerator = Icu4jTransformRules.createInputFileGenerator(inputDirNames); 905 906 // Extract the additional arguments. 907 int argIndex = inputDirNames.length; 908 String targetDir = args[argIndex++]; 909 Path corePlatformApiFile = Paths.get(args[argIndex++]); 910 Path intraCoreApiFile = Paths.get(args[argIndex++]); 911 Path unsupportedAppUsageFile = Paths.get(args[argIndex++]); 912 913 // Ensure that all the arguments were used. 914 if (argIndex != args.length) { 915 throw new IllegalArgumentException(COMMAND_USAGE); 916 } 917 918 rules = createTransformRules(corePlatformApiFile, intraCoreApiFile, 919 unsupportedAppUsageFile, allowlistedApiPath); 920 outputSourceFileGenerator = Icu4jTransformRules.createOutputFileGenerator(targetDir); 921 } 922 923 @Override getRuleList(File ignored)924 public List<Rule> getRuleList(File ignored) { 925 return rules; 926 } 927 928 @Override getInputFileGenerator()929 public InputFileGenerator getInputFileGenerator() { 930 return inputFileGenerator; 931 } 932 933 @Override getOutputSourceFileGenerator()934 public OutputSourceFileGenerator getOutputSourceFileGenerator() { 935 return outputSourceFileGenerator; 936 } 937 938 // Rules for migrating com.ibm.icu source over to android.icu. Pulled out separately so they 939 // can be used for modifying ICU4J sample code as well. getRepackagingRules()940 static Rule[] getRepackagingRules() { 941 return new Rule[] { 942 // Doc change: Insert a warning about the source code being generated. 943 createMandatoryRule(new InsertHeader(SOURCE_CODE_HEADER)), 944 // AST change: Change the package of each CompilationUnit from com.ibm.icu to android.icu. 945 createMandatoryRule(new RenamePackage(ORIGINAL_ICU_PACKAGE, ANDROID_ICU_PACKAGE)), 946 // AST change: Change all qualified names in code and javadoc. 947 createOptionalRule(new ModifyQualifiedNames(ORIGINAL_ICU_PACKAGE, ANDROID_ICU_PACKAGE)), 948 // AST change: Change all string literals containing package names in code. 949 createOptionalRule(new ModifyStringLiterals(ORIGINAL_ICU_PACKAGE, ANDROID_ICU_PACKAGE)), 950 // AST change: Change all string literals containing paths in code. 951 createOptionalRule(new ModifyStringLiterals("com/ibm/icu", "android/icu")), 952 }; 953 } 954 createTransformRules(Path corePlatformApiFile, Path intraCoreApiFile, Path unsupportedAppUsagePath, Path allowlistedApiPath)955 private static List<Rule> createTransformRules(Path corePlatformApiFile, 956 Path intraCoreApiFile, 957 Path unsupportedAppUsagePath, 958 Path allowlistedApiPath) { 959 // The rules needed to repackage source code that declares or references com.ibm.icu code 960 // so it references android.icu instead. 961 Rule[] repackageRules = getRepackagingRules(); 962 963 // The rules needed to fix up Android's documentation rules. 964 Rule[] apiDocsRules = new Rule[] { 965 // Below are the fixes that ensure the Android API documentation generation can be run 966 // over the source. 967 968 // Doc change: Switch all documentation references from com.ibm.icu to android.icu. 969 // e.g. importantly in <code> blocks and unimportantly in non-Javadoc comments. 970 createOptionalRule( 971 new ReplaceTextCommentScanner(ORIGINAL_ICU_PACKAGE, ANDROID_ICU_PACKAGE)), 972 973 // AST change: Hide all ICU public classes except those in the PUBLIC_API_CLASSES 974 // allowlist. 975 createHidePublicClassesRule(), 976 977 // AST change: Hide ICU methods that are in INITIAL_DEPRECATED_SET and Android does not 978 // want to make public. 979 createHideOriginalDeprecatedClassesRule(), 980 // AST change: Explicitly hide blocklisted methods in DECLARATIONS_TO_HIDE such as those 981 // that get/set static default values that might lead to confusion or strange interactions 982 // between Android's ICU4J and java.text / java.util classes. 983 createHideBlocklistedDeclarationsRule(), 984 // AST change: Explicitly hide any elements that are marked as 985 // @draft / @provisional / @internal 986 createOptionalRule(new HideDraftProvisionalInternal()), 987 988 // AST change: Hide new non-allowlisted API in Android temporarily 989 // Usually used for avoiding the new API introduced by upstream to show up in Android. 990 createHideNonAllowlistedRule(allowlistedApiPath), 991 992 // AST change: Add @Deprecated annotation and @deprecated doc to deprecated API in Android 993 createMarkElementsWithDeprecatedAnnotationRule(), 994 createMarkElementsWithDeprecatedJavadocTagRule(), 995 996 // AST change: Add @removed doc to removed API in Android 997 createMarkElementsWithRemovedJavadocTagRule(), 998 999 1000 // AST change: Remove JavaDoc tags that Android has no need of: 1001 // @hide has been added in place of @draft, @provisional and @internal 1002 // @stable <ICU version> will not mean much on Android. 1003 createOptionalRule(new RemoveJavaDocTags( 1004 "@stable", "@draft", "@provisional", "@internal", "@since")), 1005 // AST change: Replace @icu and @icuenhanced with standard text. 1006 createOptionalRule(new ReplaceIcuTags()), 1007 1008 // AST change: Translate some of the @.jcite tags used by ICU into @sample tags used by 1009 // doclava. Those that are not translated are escaped. 1010 createTranslateJciteInclusionRule(), 1011 1012 // AST change: Add CorePlatformApi to specified classes and members 1013 createOptionalRule(AddAnnotation.markerAnnotationFromFlatFile( 1014 "libcore.api.CorePlatformApi", corePlatformApiFile)), 1015 1016 // AST change: Add CorePlatformApi to specified classes and members 1017 createOptionalRule(AddAnnotation.markerAnnotationFromFlatFile( 1018 "libcore.api.IntraCoreApi", intraCoreApiFile)), 1019 1020 // AST change: Add default constructors, must come before processor to add 1021 // UnsupportedAppUsage. 1022 createOptionalRule(new AddDefaultConstructor( 1023 TypeLocator.createLocatorsFromStrings(DEFAULT_CONSTRUCTORS))), 1024 1025 // AST change: Add UnsupportedAppUsage to specified classes and members 1026 createOptionalRule(Annotations.addUnsupportedAppUsage(unsupportedAppUsagePath)), 1027 1028 // AST change: Add @SuppressWarnings("HiddenAbstractMethod") to specified methods 1029 createHiddenAbstractMethodRule(), 1030 }; 1031 1032 List<Rule> rulesList = Lists.newArrayList(repackageRules); 1033 rulesList.addAll(Arrays.asList(apiDocsRules)); 1034 return rulesList; 1035 } 1036 createTranslateJciteInclusionRule()1037 private static Rule createTranslateJciteInclusionRule() { 1038 List<BodyDeclarationLocator> allowlist = 1039 BodyDeclarationLocators.createLocatorsFromStrings(JCITE_TRANSFORM_SET); 1040 TranslateJcite.InclusionHandler transformer = 1041 new TranslateJcite.InclusionHandler(ANDROID_ICU4J_SAMPLE_DIR, allowlist); 1042 return createOptionalRule(transformer); 1043 } 1044 createHideOriginalDeprecatedClassesRule()1045 private static Rule createHideOriginalDeprecatedClassesRule() { 1046 List<BodyDeclarationLocator> blocklist = 1047 BodyDeclarationLocators.createLocatorsFromStrings(INITIAL_DEPRECATED_SET); 1048 return createOptionalRule( 1049 new TagMatchingDeclarations(blocklist, "@hide original deprecated declaration")); 1050 } 1051 createMarkElementsWithDeprecatedAnnotationRule()1052 private static Rule createMarkElementsWithDeprecatedAnnotationRule() { 1053 List<BodyDeclarationLocator> locators = 1054 BodyDeclarationLocators.createLocatorsFromStrings( 1055 ANDROID_DEPRECATED_SET.keySet().toArray(new String[0])); 1056 return createOptionalRule(AddAnnotation.markerAnnotationFromLocators( 1057 "Deprecated", locators)); 1058 } 1059 createMarkElementsWithDeprecatedJavadocTagRule()1060 private static Rule createMarkElementsWithDeprecatedJavadocTagRule() { 1061 Map<BodyDeclarationLocator, String> locatorTags = ANDROID_DEPRECATED_SET.entrySet().stream() 1062 .collect(Collectors.toMap( 1063 (entry) -> BodyDeclarationLocators.fromStringForm(entry.getKey()), 1064 (entry) -> "@deprecated " + entry.getValue()) 1065 ); 1066 return createOptionalRule(new TagMatchingDeclarations(locatorTags)); 1067 } 1068 createMarkElementsWithRemovedJavadocTagRule()1069 private static Rule createMarkElementsWithRemovedJavadocTagRule() { 1070 List<BodyDeclarationLocator> locators = 1071 BodyDeclarationLocators.createLocatorsFromStrings(ANDROID_REMOVED_SET); 1072 return createOptionalRule(new TagMatchingDeclarations(locators, 1073 "@removed on Android but @stable in ICU")); 1074 } 1075 createHideBlocklistedDeclarationsRule()1076 private static Rule createHideBlocklistedDeclarationsRule() { 1077 List<BodyDeclarationLocator> blocklist = 1078 BodyDeclarationLocators.createLocatorsFromStrings(DECLARATIONS_TO_HIDE); 1079 return createOptionalRule( 1080 new TagMatchingDeclarations(blocklist, "@hide unsupported on Android")); 1081 } 1082 createHidePublicClassesRule()1083 private static Rule createHidePublicClassesRule() { 1084 List<TypeLocator> allowlist = TypeLocator.createLocatorsFromStrings(PUBLIC_API_CLASSES); 1085 return createOptionalRule( 1086 new HidePublicClasses(allowlist, "Only a subset of ICU is exposed in Android")); 1087 } 1088 createHiddenAbstractMethodRule()1089 private static Rule createHiddenAbstractMethodRule() { 1090 List<BodyDeclarationLocator> loactors = 1091 BodyDeclarationLocators.createLocatorsFromStrings(HIDDEN_ABSTRACT_METHODS); 1092 return createOptionalRule( 1093 AddAnnotation.markerAnnotationWithPropertyFromLocators("SuppressWarnings", 1094 "value", String.class, "HiddenAbstractMethod", loactors)); 1095 } 1096 } 1097 createHideNonAllowlistedRule(Path allowlistedApiPath)1098 private static Rule createHideNonAllowlistedRule(Path allowlistedApiPath) { 1099 List<BodyDeclarationLocator> bodyDeclarationLocators = null; 1100 if (allowlistedApiPath != null) { 1101 bodyDeclarationLocators = BodyDeclarationLocators.readBodyDeclarationLocators( 1102 allowlistedApiPath); 1103 } 1104 return createOptionalRule(new HideNonAllowlistedDeclarations(bodyDeclarationLocators, 1105 "@hide Hide new API in Android temporarily")); 1106 } 1107 } 1108