在 java 类 java.util.Locale 中,我发现关键字transient 标记了一个方法。
public final class Locale
implements Cloneable, Serializable
{
private static class LocaleNameGetter
implements sun.util.LocaleServiceProviderPool.LocalizedObjectGetter
{
public transient String getObject(LocaleNameProvider localenameprovider, Locale locale, String s, Object aobj[])
{
if(!$assertionsDisabled && aobj.length != 2)
throw new AssertionError();
int i = ((Integer)aobj[0]).intValue();
String s1 = (String)aobj[1];
switch(i)
{
case 0: // '\0'
return localenameprovider.getDisplayLanguage(s1, locale);
case 1: // '\001'
return localenameprovider.getDisplayCountry(s1, locale);
case 2: // '\002'
return localenameprovider.getDisplayVariant(s1, locale);
}
if(!$assertionsDisabled)
throw new AssertionError();
else
return null;
}
有人能告诉我为什么会这样吗?