Skip to content

Commit 4e5f913

Browse files
jeannielynnmoultonsvorenova
authored and
svorenova
committed
Adding unit tests for extracting generic bases' info
1 parent 2c8fc0f commit 4e5f913

29 files changed

+618
-24
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

unit/java_bytecode/java_bytecode_parse_generics/DerivedGenericInst.java

-4
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

unit/java_bytecode/java_bytecode_parse_generics/DerivedGenericUninst.java

-4
This file was deleted.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
public class DerivedGenerics {
2+
DerivedGenericInst new1;
3+
DerivedGenericInst2 new2;
4+
DerivedGenericUninst<Integer> new3;
5+
DerivedGenericMixed1<String> new4;
6+
DerivedGenericMixed2<String> new5;
7+
ExtendsNotGeneric new6;
8+
ContainsInnerClass new7;
9+
ContainsInnerClassGeneric<String> new8;
10+
ThreeHierarchy new9;
11+
ImplementsInterface new10;
12+
ImplementsInterfaceGenericSpecialised new11;
13+
ImplementsInterfaceGenericUnspec<String> new12;
14+
ImplementsMultipleInterfaces new13;
15+
ExtendsAndImplements new14;
16+
ExtendsAndImplementsGeneric new15;
17+
}
18+
19+
class DerivedGenericInst extends Generic<Interface_Implementation>
20+
{
21+
// This class is to test instantiating a non-generic subclass of a generic class
22+
// with the base class having only one type parameter.
23+
}
24+
25+
class DerivedGenericInst2 extends
26+
GenericTwoParam<Interface_Implementation,Integer>
27+
{
28+
// This class is to test instantiating a non-generic subclass of a generic class
29+
// with the base class having two type parameters.
30+
}
31+
32+
class DerivedGenericUninst<T> extends Generic<T>
33+
{
34+
T newField;
35+
36+
// This class is to test instantiating a generic subclass of a generic class
37+
// with the base class having only one parameter, but the type parameter is
38+
// not specialised.
39+
}
40+
41+
class DerivedGenericMixed1<T> extends Generic<Interface_Implementation>
42+
{
43+
T newField;
44+
45+
// This class is to test instantiating a generic subclass of a generic class
46+
// with the base class having only one type parameter.
47+
}
48+
49+
class DerivedGenericMixed2<T> extends GenericTwoParam<T, Integer>
50+
{
51+
T newField;
52+
53+
// This class is to test instantiating a generic subclass of a generic class
54+
// with the base class having two type parameters, where one is specialised
55+
// and the other is not.
56+
}
57+
58+
class NotGeneric {
59+
int field;
60+
}
61+
62+
class ExtendsNotGeneric extends NotGeneric {
63+
}
64+
65+
class ContainsInnerClass {
66+
67+
InnerClass ic;
68+
InnerClassGeneric<String> icg;
69+
70+
// This class is to test inner classes that extend generic types.
71+
class InnerClass extends Generic<Integer> {
72+
}
73+
74+
class InnerClassGeneric<T> extends Generic<T> {
75+
}
76+
}
77+
78+
class ContainsInnerClassGeneric<T> {
79+
80+
InnerClass ic;
81+
82+
// This class is to test inner classes that extend generic types when the
83+
// outer class in generic.
84+
class InnerClass extends Generic<T> {
85+
}
86+
}
87+
88+
class ThreeHierarchy extends DerivedGenericMixed2<String> {
89+
90+
// This class extends a specialised class that extends another generic
91+
// class.
92+
93+
}
94+
95+
class ImplementsInterface implements Interface {
96+
97+
public int getX() {
98+
return 0;
99+
}
100+
101+
}
102+
103+
class ImplementsInterfaceGenericSpecialised implements InterfaceGeneric<Integer>
104+
{
105+
106+
public Integer someMethod() {
107+
return 0;
108+
}
109+
110+
}
111+
112+
class ImplementsInterfaceGenericUnspec<E> implements InterfaceGeneric<E> {
113+
114+
public E someMethod() {
115+
return null;
116+
}
117+
118+
}
119+
120+
class ImplementsMultipleInterfaces implements
121+
InterfaceGeneric<Integer>, Interface
122+
{
123+
124+
public Integer someMethod() {
125+
return 0;
126+
}
127+
128+
public int getX() {
129+
return 0;
130+
}
131+
}
132+
133+
class ExtendsAndImplements extends Generic<Integer> implements Interface,
134+
InterfaceGeneric<Integer>
135+
{
136+
public Integer someMethod() {
137+
return 0;
138+
}
139+
140+
public int getX() {
141+
return 0;
142+
}
143+
}
144+
145+
class ExtendsAndImplementsGeneric<T> extends GenericTwoParam<T, Integer>
146+
implements Interface,
147+
InterfaceGeneric<T>
148+
{
149+
T f;
150+
151+
public T someMethod() {
152+
return f;
153+
}
154+
155+
public int getX() {
156+
return 0;
157+
}
158+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface InterfaceGeneric<E>
2+
{
3+
E someMethod();
4+
}
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)