Skip to content

Commit e166b55

Browse files
committed
Apache/Oracle differences in Collections generic variables
<E> vs <T> in Singleton
1 parent ea3c7d4 commit e166b55

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed
-35 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/util/Collections.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
* limitations under the License.
1616
*/
1717

18+
// BH SwingJS: This class needs to be checked for consistency with Oracle Java 7
19+
// generics T vs E, for example.
20+
1821
package java.util;
1922

2023
import java.io.IOException;
2124
import java.io.ObjectOutputStream;
2225
import java.io.Serializable;
2326
import java.lang.reflect.Array;
2427

25-
// BH: private superclasses must precede their subclasses because J2S keeps these in the same file.
2628

2729
/**
2830
* Collections contains static methods which operate on Collection classes.
@@ -197,12 +199,12 @@ public int compare(T o1, T o2) {
197199
}
198200
}
199201

200-
private static final class SingletonSet<E> extends AbstractSet<E> implements Serializable {
202+
private static final class SingletonSet<T> extends AbstractSet<T> implements Serializable {
201203
private static final long serialVersionUID = 3193687207550431679L;
202204

203-
final E element;
205+
final T element;
204206

205-
SingletonSet(E object) {
207+
SingletonSet(T object) {
206208
element = object;
207209
}
208210

@@ -217,15 +219,15 @@ public int size() {
217219
}
218220

219221
@Override
220-
public Iterator<E> iterator() {
221-
return new Iterator<E>() {
222+
public Iterator<T> iterator() {
223+
return new Iterator<T>() {
222224
boolean hasNext = true;
223225

224226
public boolean hasNext() {
225227
return hasNext;
226228
}
227229

228-
public E next() {
230+
public T next() {
229231
if (hasNext) {
230232
hasNext = false;
231233
return element;
@@ -240,12 +242,12 @@ public void remove() {
240242
}
241243
}
242244

243-
private static final class SingletonList<E> extends AbstractList<E> implements Serializable {
245+
private static final class SingletonList<T> extends AbstractList<T> implements Serializable {
244246
private static final long serialVersionUID = 3093736618740652951L;
245247

246-
final E element;
248+
final T element;
247249

248-
SingletonList(E object) {
250+
SingletonList(T object) {
249251
element = object;
250252
}
251253

@@ -255,7 +257,7 @@ public boolean contains(Object object) {
255257
}
256258

257259
@Override
258-
public E get(int location) {
260+
public T get(int location) {
259261
if (location == 0) {
260262
return element;
261263
}

0 commit comments

Comments
 (0)