< prev index next >

src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java

Print this page
rev 12962 : 8136967: revert all changes applied to obtain information about 8131129


 387             if (d != null)  return d;
 388             extensions[ord] = d = get(typeChars+type.basicTypeChar());
 389             return d;
 390         }
 391 
 392         private static SpeciesData get(String types) {
 393             // Acquire cache lock for query.
 394             SpeciesData d = lookupCache(types);
 395             if (!d.isPlaceholder())
 396                 return d;
 397             synchronized (d) {
 398                 // Use synch. on the placeholder to prevent multiple instantiation of one species.
 399                 // Creating this class forces a recursive call to getForClass.
 400                 if (lookupCache(types).isPlaceholder())
 401                     Factory.generateConcreteBMHClass(types);
 402             }
 403             // Reacquire cache lock.
 404             d = lookupCache(types);
 405             // Class loading must have upgraded the cache.
 406             assert(d != null && !d.isPlaceholder());
 407             if (OBSERVE_BMH_SPECIES_CREATION) {
 408                 if (d == null) {
 409                     throw new IllegalStateException("d == null");
 410                 }
 411                 if (d.isPlaceholder()) {
 412                     throw new IllegalStateException("d is place holder");
 413                 }
 414             }
 415             return d;
 416         }
 417         static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) {
 418             // clazz is a new class which is initializing its SPECIES_DATA field
 419             return updateCache(types, new SpeciesData(types, clazz));
 420         }
 421         private static synchronized SpeciesData lookupCache(String types) {
 422             SpeciesData d = CACHE.get(types);
 423             if (d != null)  return d;
 424             d = new SpeciesData(types);
 425             assert(d.isPlaceholder());
 426             if (OBSERVE_BMH_SPECIES_CREATION && !d.isPlaceholder()) {
 427                 throw new IllegalStateException("d is not place holder");
 428             }
 429             CACHE.put(types, d);
 430             return d;
 431         }
 432         private static synchronized SpeciesData updateCache(String types, SpeciesData d) {
 433             SpeciesData d2;
 434             assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder());
 435             assert(!d.isPlaceholder());
 436             if (OBSERVE_BMH_SPECIES_CREATION) {
 437                 d2 = CACHE.get(types);
 438                 if (d2 != null && !d2.isPlaceholder()) {
 439                     throw new IllegalStateException("non-null d2 is not place holder");
 440                 }
 441                 if (d.isPlaceholder()) {
 442                     throw new IllegalStateException("d is place holder");
 443                 }
 444             }
 445             CACHE.put(types, d);
 446             return d;
 447         }
 448 
 449         static {
 450             // pre-fill the BMH speciesdata cache with BMH's inner classes
 451             final Class<BoundMethodHandle> rootCls = BoundMethodHandle.class;
 452             try {
 453                 for (Class<?> c : rootCls.getDeclaredClasses()) {
 454                     if (rootCls.isAssignableFrom(c)) {
 455                         final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
 456                         SpeciesData d = Factory.speciesDataFromConcreteBMHClass(cbmh);
 457                         assert(d != null) : cbmh.getName();
 458                         assert(d.clazz == cbmh);
 459                         assert(d == lookupCache(d.typeChars));
 460                     }
 461                 }
 462             } catch (Throwable e) {
 463                 throw newInternalError(e);
 464             }




 387             if (d != null)  return d;
 388             extensions[ord] = d = get(typeChars+type.basicTypeChar());
 389             return d;
 390         }
 391 
 392         private static SpeciesData get(String types) {
 393             // Acquire cache lock for query.
 394             SpeciesData d = lookupCache(types);
 395             if (!d.isPlaceholder())
 396                 return d;
 397             synchronized (d) {
 398                 // Use synch. on the placeholder to prevent multiple instantiation of one species.
 399                 // Creating this class forces a recursive call to getForClass.
 400                 if (lookupCache(types).isPlaceholder())
 401                     Factory.generateConcreteBMHClass(types);
 402             }
 403             // Reacquire cache lock.
 404             d = lookupCache(types);
 405             // Class loading must have upgraded the cache.
 406             assert(d != null && !d.isPlaceholder());








 407             return d;
 408         }
 409         static SpeciesData getForClass(String types, Class<? extends BoundMethodHandle> clazz) {
 410             // clazz is a new class which is initializing its SPECIES_DATA field
 411             return updateCache(types, new SpeciesData(types, clazz));
 412         }
 413         private static synchronized SpeciesData lookupCache(String types) {
 414             SpeciesData d = CACHE.get(types);
 415             if (d != null)  return d;
 416             d = new SpeciesData(types);
 417             assert(d.isPlaceholder());



 418             CACHE.put(types, d);
 419             return d;
 420         }
 421         private static synchronized SpeciesData updateCache(String types, SpeciesData d) {
 422             SpeciesData d2;
 423             assert((d2 = CACHE.get(types)) == null || d2.isPlaceholder());
 424             assert(!d.isPlaceholder());









 425             CACHE.put(types, d);
 426             return d;
 427         }
 428 
 429         static {
 430             // pre-fill the BMH speciesdata cache with BMH's inner classes
 431             final Class<BoundMethodHandle> rootCls = BoundMethodHandle.class;
 432             try {
 433                 for (Class<?> c : rootCls.getDeclaredClasses()) {
 434                     if (rootCls.isAssignableFrom(c)) {
 435                         final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
 436                         SpeciesData d = Factory.speciesDataFromConcreteBMHClass(cbmh);
 437                         assert(d != null) : cbmh.getName();
 438                         assert(d.clazz == cbmh);
 439                         assert(d == lookupCache(d.typeChars));
 440                     }
 441                 }
 442             } catch (Throwable e) {
 443                 throw newInternalError(e);
 444             }


< prev index next >