Skip to content

Commit 50dcec8

Browse files
jeannielynnmoultonsvorenova
authored and
svorenova
committed
Adding unit tests for extracting generic bases' info
1 parent 54df3a1 commit 50dcec8

30 files changed

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