Skip to content

Commit e555bd2

Browse files
zhangskzcopybara-github
authored andcommitted
Breaking change: Remove deprecated runtime methods for compatibility with old v2.x.x gencode.
These methods were deprecated as of 3.0.0 and were originally added for compatibility with gencode from old major versions (v2.x.x.) which are long out of our Cross Version Runtime Guarantees: https://protobuf.dev/support/cross-version-runtime-guarantee/ PiperOrigin-RevId: 587099512
1 parent dfb8a4c commit e555bd2

2 files changed

Lines changed: 1 addition & 68 deletions

File tree

java/core/src/main/java/com/google/protobuf/AbstractMessage.java

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -538,44 +538,4 @@ public BuilderType mergeFrom(
538538
return (BuilderType) super.mergeFrom(input, extensionRegistry);
539539
}
540540
}
541-
542-
/**
543-
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
544-
* generated code.
545-
*/
546-
@Deprecated
547-
protected static int hashLong(long n) {
548-
return (int) (n ^ (n >>> 32));
549-
}
550-
551-
/**
552-
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
553-
* generated code.
554-
*/
555-
@Deprecated
556-
protected static int hashBoolean(boolean b) {
557-
return b ? 1231 : 1237;
558-
}
559-
560-
/**
561-
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
562-
* generated code.
563-
*/
564-
@Deprecated
565-
protected static int hashEnum(EnumLite e) {
566-
return e.getNumber();
567-
}
568-
569-
/**
570-
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1
571-
* generated code.
572-
*/
573-
@Deprecated
574-
protected static int hashEnumList(List<? extends EnumLite> list) {
575-
int hash = 1;
576-
for (EnumLite e : list) {
577-
hash = 31 * hash + hashEnum(e);
578-
}
579-
return hash;
580-
}
581541
}

java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ protected Object readResolve() throws ObjectStreamException {
14401440
} catch (ClassNotFoundException e) {
14411441
throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e);
14421442
} catch (NoSuchFieldException e) {
1443-
return readResolveFallback();
1443+
throw new RuntimeException("Unable to find DEFAULT_INSTANCE in " + messageClassName, e);
14441444
} catch (SecurityException e) {
14451445
throw new RuntimeException("Unable to call DEFAULT_INSTANCE in " + messageClassName, e);
14461446
} catch (IllegalAccessException e) {
@@ -1450,33 +1450,6 @@ protected Object readResolve() throws ObjectStreamException {
14501450
}
14511451
}
14521452

1453-
/**
1454-
* @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code.
1455-
*/
1456-
@Deprecated
1457-
private Object readResolveFallback() throws ObjectStreamException {
1458-
try {
1459-
Class<?> messageClass = resolveMessageClass();
1460-
java.lang.reflect.Field defaultInstanceField =
1461-
messageClass.getDeclaredField("defaultInstance");
1462-
defaultInstanceField.setAccessible(true);
1463-
MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null);
1464-
return defaultInstance.newBuilderForType()
1465-
.mergeFrom(asBytes)
1466-
.buildPartial();
1467-
} catch (ClassNotFoundException e) {
1468-
throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e);
1469-
} catch (NoSuchFieldException e) {
1470-
throw new RuntimeException("Unable to find defaultInstance in " + messageClassName, e);
1471-
} catch (SecurityException e) {
1472-
throw new RuntimeException("Unable to call defaultInstance in " + messageClassName, e);
1473-
} catch (IllegalAccessException e) {
1474-
throw new RuntimeException("Unable to call parsePartialFrom", e);
1475-
} catch (InvalidProtocolBufferException e) {
1476-
throw new RuntimeException("Unable to understand proto buffer", e);
1477-
}
1478-
}
1479-
14801453
private Class<?> resolveMessageClass() throws ClassNotFoundException {
14811454
return messageClass != null ? messageClass : Class.forName(messageClassName);
14821455
}

0 commit comments

Comments
 (0)