Skip to content

Commit 1dfb5cd

Browse files
author
Matthias Güdemann
authored
Merge pull request #1871 from mgudemann/bugfix/superclass_references_for_implicit_generic
[TG-2585] Support implicitly generic superclasses
2 parents 71b32f4 + 25eb1a3 commit 1dfb5cd

12 files changed

+93
-2
lines changed

src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ extract_generic_superclass_reference(const optionalt<std::string> &signature)
112112
signature.value().substr(start, (end - start) + 1);
113113

114114
// if the superclass is generic then the reference is of form
115-
// Lsuperclass-name<generic-types;>;
116-
if(has_suffix(superclass_ref, ">;"))
115+
// `Lsuperclass-name<generic-types;>;` if it is implicitly generic, then the
116+
// reference is of the form
117+
// `Lsuperclass-name<Tgeneric-types;>.Innerclass-Name`
118+
if(superclass_ref.find('<') != std::string::npos)
117119
return superclass_ref;
118120
}
119121
return {};
497 Bytes
Binary file not shown.

unit/java_bytecode/java_bytecode_parse_generics/DerivedGenerics.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public class DerivedGenerics {
1515
ExtendsAndImplementsSameInterface new14;
1616
ExtendsAndImplementsSameInterface2 new15;
1717
ExtendsAndImplementsSameInterfaceGeneric new16;
18+
GenericBase<?>.ExtendImplicit new17;
19+
GenericBase<?>.ExtendImplicitAndExplicit<?> new18;
20+
GenericBase2<?, ?>.ExtendImplicitAndExplicit new19;
1821
}
1922

2023
class DerivedGenericInst extends Generic<Interface_Implementation>
@@ -189,3 +192,25 @@ public Class<? extends Class> someMethod(){
189192
return null;
190193
}
191194
}
195+
196+
// This class exists to test that subclasses of implicit generic classes have a
197+
// base class entry which is a Java generic symbol.
198+
class GenericBase<T> {
199+
class ImplicitGeneric {
200+
}
201+
class ExtendImplicit extends ImplicitGeneric {
202+
}
203+
class ImplicitAndExplicitGeneric<S> {
204+
}
205+
class ExtendImplicitAndExplicit<S> extends ImplicitAndExplicitGeneric<S> {
206+
}
207+
}
208+
209+
// This class exists to test the subclasses of generic and implicitly generic
210+
// classes have a base class entry which is a Java generic symbol.
211+
class GenericBase2<T, S> {
212+
class ImplicitAndExplicitGeneric<S> {
213+
}
214+
class ExtendImplicitAndExplicit extends ImplicitAndExplicitGeneric<S> {
215+
}
216+
}
436 Bytes
Binary file not shown.
518 Bytes
Binary file not shown.
434 Bytes
Binary file not shown.
349 Bytes
Binary file not shown.
562 Bytes
Binary file not shown.
505 Bytes
Binary file not shown.
438 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)