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