@@ -236,29 +236,72 @@ static String underscoresToCamelCase(String input) {
236236 return underscoresToCamelCase (input , /* capitalizeNextLetter= */ true );
237237 }
238238
239- /** Returns the fully qualified Java class name for the given message descriptor. */
240- public static String getClassName (Descriptor message ) {
239+ /**
240+ * Returns the fully qualified Java bytecode class name for the given message descriptor.
241+ *
242+ * <p>Nested classes will use '$' as the separator, rather than '.'.
243+ */
244+ public static String getBytecodeClassName (Descriptor message ) {
241245 // Replicates the logic for ClassName from immutable/names.h
242246 return getClassFullName (
243247 getClassNameWithoutPackage (message ), message .getFile (), !getNestInFileClass (message ));
244248 }
245249
246- /** Returns the fully qualified Java class name for the given enum descriptor. */
247- public static String getClassName (EnumDescriptor enm ) {
250+ /**
251+ * Returns the fully qualified Java bytecode class name for the given enum descriptor.
252+ *
253+ * <p>Nested classes will use '$' as the separator, rather than '.'.
254+ */
255+ public static String getBytecodeClassName (EnumDescriptor enm ) {
248256 // Replicates the logic for ClassName from immutable/names.h
249257 return getClassFullName (
250258 getClassNameWithoutPackage (enm ), enm .getFile (), !getNestInFileClass (enm ));
251259 }
252260
253- /** Returns the fully qualified Java class name for the given service descriptor. */
254- static String getClassName (ServiceDescriptor service ) {
261+ /**
262+ * Returns the fully qualified Java bytecode class name for the given service descriptor.
263+ *
264+ * <p>Nested classes will use '$' as the separator, rather than '.'.
265+ */
266+ static String getBytecodeClassName (ServiceDescriptor service ) {
255267 // Replicates the logic for ClassName from immutable/names.h
256268 String suffix = "" ;
257269 boolean isOwnFile = !getNestInFileClass (service );
258270 return getClassFullName (getClassNameWithoutPackage (service ), service .getFile (), isOwnFile )
259271 + suffix ;
260272 }
261273
274+ static String getQualifiedFromBytecodeClassName (String bytecodeClassName ) {
275+ return bytecodeClassName .replace ('$' , '.' );
276+ }
277+
278+ /**
279+ * Returns the fully qualified Java class name for the given message descriptor.
280+ *
281+ * <p>Nested classes will use '.' as the separator, rather than '$'.
282+ */
283+ public static String getQualifiedClassName (Descriptor message ) {
284+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (message ));
285+ }
286+
287+ /**
288+ * Returns the fully qualified Java class name for the given enum descriptor.
289+ *
290+ * <p>Nested classes will use '.' as the separator, rather than '$'.
291+ */
292+ public static String getQualifiedClassName (EnumDescriptor enm ) {
293+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (enm ));
294+ }
295+
296+ /**
297+ * Returns the fully qualified Java class name for the given service descriptor.
298+ *
299+ * <p>Nested classes will use '.' as the separator, rather than '$'.
300+ */
301+ public static String getQualifiedClassName (ServiceDescriptor service ) {
302+ return getQualifiedFromBytecodeClassName (getBytecodeClassName (service ));
303+ }
304+
262305 private static String getClassFullName (
263306 String nameWithoutPackage , FileDescriptor file , boolean isOwnFile ) {
264307 // Replicates the logic for ClassNameResolver::GetJavaClassFullName from immutable/names.cc
0 commit comments