< prev index next >

jdk/test/java/beans/XMLDecoder/8028054/TestConstructorFinder.java

Print this page




  22  */
  23 
  24 import com.sun.beans.finder.ConstructorFinder;
  25 
  26 import java.lang.reflect.Constructor;
  27 import java.util.ArrayList;
  28 import java.util.Collections;
  29 import java.util.List;
  30 
  31 /*
  32  * @test
  33  * @bug 8028054
  34  * @summary Tests that cached constructors have synchronized access
  35  * @author Sergey Malenkov
  36  * @modules java.desktop/com.sun.beans.finder
  37  *          java.activation
  38  *          java.transaction
  39  *          java.corba
  40  *          java.xml.bind
  41  * @compile -XDignore.symbol.file TestConstructorFinder.java
  42  * @run main/othervm -addmods java.activation -addmods java.transaction -addmods java.corba -addmods java.xml.bind TestConstructorFinder
  43  */
  44 
  45 public class TestConstructorFinder {
  46     public static void main(String[] args) throws Exception {
  47         List<Class<?>> classes = Task.getClasses(Integer.MAX_VALUE);
  48         List<Constructor> constructors = new ArrayList<>();
  49         for (Class<?> type : classes) {
  50             Collections.addAll(constructors, type.getConstructors());
  51         }
  52         Task.print("found " + constructors.size() + " constructors in " + classes.size() + " classes");
  53 
  54         List<Task> tasks = new ArrayList<>();
  55         for (int i = 0; i < 50; i++) {
  56             tasks.add(new Task<Constructor>(constructors) {
  57                 @Override
  58                 protected void process(Constructor constructor) throws NoSuchMethodException {
  59                     ConstructorFinder.findConstructor(constructor.getDeclaringClass(), constructor.getParameterTypes());
  60                 }
  61             });
  62         }




  22  */
  23 
  24 import com.sun.beans.finder.ConstructorFinder;
  25 
  26 import java.lang.reflect.Constructor;
  27 import java.util.ArrayList;
  28 import java.util.Collections;
  29 import java.util.List;
  30 
  31 /*
  32  * @test
  33  * @bug 8028054
  34  * @summary Tests that cached constructors have synchronized access
  35  * @author Sergey Malenkov
  36  * @modules java.desktop/com.sun.beans.finder
  37  *          java.activation
  38  *          java.transaction
  39  *          java.corba
  40  *          java.xml.bind
  41  * @compile -XDignore.symbol.file TestConstructorFinder.java
  42  * @run main/othervm --add-modules=java.activation,java.transaction,java.corba,java.xml.bind TestConstructorFinder
  43  */
  44 
  45 public class TestConstructorFinder {
  46     public static void main(String[] args) throws Exception {
  47         List<Class<?>> classes = Task.getClasses(Integer.MAX_VALUE);
  48         List<Constructor> constructors = new ArrayList<>();
  49         for (Class<?> type : classes) {
  50             Collections.addAll(constructors, type.getConstructors());
  51         }
  52         Task.print("found " + constructors.size() + " constructors in " + classes.size() + " classes");
  53 
  54         List<Task> tasks = new ArrayList<>();
  55         for (int i = 0; i < 50; i++) {
  56             tasks.add(new Task<Constructor>(constructors) {
  57                 @Override
  58                 protected void process(Constructor constructor) throws NoSuchMethodException {
  59                     ConstructorFinder.findConstructor(constructor.getDeclaringClass(), constructor.getParameterTypes());
  60                 }
  61             });
  62         }


< prev index next >