Skip to content

Commit 5a70dc4

Browse files
committed
removed unnecessaryly implemented method
1 parent 0750d4d commit 5a70dc4

File tree

1 file changed

+35
-58
lines changed

1 file changed

+35
-58
lines changed

src/classes/modules/java.base/java/lang/ClassLoader.java

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* The Java Pathfinder core (jpf-core) platform is licensed under the
77
* Apache License, Version 2.0 (the "License"); you may not use this file except
88
* in compliance with the License. You may obtain a copy of the License at
9-
*
10-
* http://www.apache.org/licenses/LICENSE-2.0.
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0.
1111
*
1212
* Unless required by applicable law or agreed to in writing, software
1313
* distributed under the License is distributed on an "AS IS" BASIS,
1414
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15-
* See the License for the specific language governing permissions and
15+
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
1818
package java.lang;
@@ -25,7 +25,6 @@
2525
import java.security.ProtectionDomain;
2626
import java.util.*;
2727
import java.util.concurrent.ConcurrentHashMap;
28-
import java.util.stream.Stream;
2928

3029
/**
3130
* @author Nastaran Shafiei <nastaran.shafiei@gmail.com>
@@ -40,8 +39,11 @@ public abstract class ClassLoader {
4039
private int nativeId;
4140

4241
//--- internals
42+
43+
// This variable is to provide support for definePackage(String,Module) method
4344
private ConcurrentHashMap<String, NamedPackage> packages
4445
= new ConcurrentHashMap<>();
46+
4547
protected ClassLoader() {
4648
// constructed on the native side
4749
}
@@ -269,11 +271,39 @@ protected Package definePackage(String name, String specTitle, String specVersio
269271
throw new UnsupportedOperationException();
270272
}
271273

274+
/**
275+
* Written as a replacement for the auxiliary class {@link CompoundEnumeration}
276+
*/
277+
final class EnumerationAdapter<E> implements Enumeration<E> {
278+
private final Iterator<E> iterator;
279+
280+
public EnumerationAdapter(Collection<E> collection) {
281+
iterator = collection.iterator();
282+
}
283+
284+
@Override
285+
public boolean hasMoreElements() {
286+
return iterator.hasNext();
287+
}
288+
289+
@Override
290+
public E nextElement() {
291+
return iterator.next();
292+
}
293+
}
294+
295+
public native final Package getDefinedPackage(final String name);
296+
297+
public native final Package[] getDefinedPackages();
298+
299+
/**
300+
* some extra implementation to support for Class.getPackage() method
301+
*/
272302
Package definePackage(String name, Module m) {
273303
if (name.isEmpty() && m.isNamed()) {
274304
throw new InternalError("unnamed package in " + m);
275305
}
276-
306+
277307
if(packages == null)
278308
packages = new ConcurrentHashMap<>();
279309

@@ -296,66 +326,13 @@ private Package toPackage(String name, NamedPackage p, Module m) {
296326

297327
return NamedPackage.toPackage(p.packageName(), p.module());
298328
}
299-
300-
/**
301-
* Written as a replacement for the auxiliary class {@link CompoundEnumeration}
302-
*/
303-
final class EnumerationAdapter<E> implements Enumeration<E> {
304-
private final Iterator<E> iterator;
305-
306-
public EnumerationAdapter(Collection<E> collection) {
307-
iterator = collection.iterator();
308-
}
309-
310-
@Override
311-
public boolean hasMoreElements() {
312-
return iterator.hasNext();
313-
}
314-
315-
@Override
316-
public E nextElement() {
317-
return iterator.next();
318-
}
319-
}
320329

321-
322330
Package definePackage(Class<?> c) {
323331
if (c.isPrimitive() || c.isArray()) {
324332
return null;
325333
}
326334

327335
return definePackage(c.getPackageName(), c.getModule());
328336
}
329-
330-
//public native final Package getDefinedPackage(final String name);
331-
332-
public final Package getDefinedPackage(String name) {
333-
System.out.println(name);
334-
Objects.requireNonNull(name, "name cannot be null");
335-
336-
NamedPackage p = packages.get(name);
337-
System.out.println(p.packageName());
338-
if (p == null)
339-
return null;
340-
341-
return definePackage(name, p.module());
342-
}
343-
public final Module getModule(String name){
344-
345-
NamedPackage p = packages.get(name);
346-
return p.module();
347-
348-
};
349-
//public native final Package[] getDefinedPackages();
350-
351-
public final Package[] getDefinedPackages() {
352-
return packages().toArray(Package[]::new);
353-
}
354-
355-
Stream<Package> packages() {
356-
return packages.values().stream()
357-
.map(p -> definePackage(p.packageName(), p.module()));
358-
}
359-
360337
}
361338

0 commit comments

Comments
 (0)