src/share/classes/sun/nio/ch/Util.java

Print this page
rev 10195 : 8048267: Replace uses of 'new Long()' with appropriate alternative across core classes
Reviewed-by: chegar, psandoz
Contributed-by: otaviojava@java.net


 312                     } catch (ClassNotFoundException   |
 313                              NoSuchMethodException    |
 314                              IllegalArgumentException |
 315                              ClassCastException x) {
 316                         throw new InternalError(x);
 317                     }
 318                     return null;
 319                 }});
 320     }
 321 
 322     static MappedByteBuffer newMappedByteBuffer(int size, long addr,
 323                                                 FileDescriptor fd,
 324                                                 Runnable unmapper)
 325     {
 326         MappedByteBuffer dbb;
 327         if (directByteBufferConstructor == null)
 328             initDBBConstructor();
 329         try {
 330             dbb = (MappedByteBuffer)directByteBufferConstructor.newInstance(
 331               new Object[] { new Integer(size),
 332                              new Long(addr),
 333                              fd,
 334                              unmapper });
 335         } catch (InstantiationException |
 336                  IllegalAccessException |
 337                  InvocationTargetException e) {
 338             throw new InternalError(e);
 339         }
 340         return dbb;
 341     }
 342 
 343     private static volatile Constructor<?> directByteBufferRConstructor = null;
 344 
 345     private static void initDBBRConstructor() {
 346         AccessController.doPrivileged(new PrivilegedAction<Void>() {
 347                 public Void run() {
 348                     try {
 349                         Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
 350                         Constructor<?> ctor = cl.getDeclaredConstructor(
 351                             new Class<?>[] { int.class,
 352                                              long.class,


 357                     } catch (ClassNotFoundException |
 358                              NoSuchMethodException |
 359                              IllegalArgumentException |
 360                              ClassCastException x) {
 361                         throw new InternalError(x);
 362                     }
 363                     return null;
 364                 }});
 365     }
 366 
 367     static MappedByteBuffer newMappedByteBufferR(int size, long addr,
 368                                                  FileDescriptor fd,
 369                                                  Runnable unmapper)
 370     {
 371         MappedByteBuffer dbb;
 372         if (directByteBufferRConstructor == null)
 373             initDBBRConstructor();
 374         try {
 375             dbb = (MappedByteBuffer)directByteBufferRConstructor.newInstance(
 376               new Object[] { new Integer(size),
 377                              new Long(addr),
 378                              fd,
 379                              unmapper });
 380         } catch (InstantiationException |
 381                  IllegalAccessException |
 382                  InvocationTargetException e) {
 383             throw new InternalError(e);
 384         }
 385         return dbb;
 386     }
 387 
 388 
 389     // -- Bug compatibility --
 390 
 391     private static volatile String bugLevel = null;
 392 
 393     static boolean atBugLevel(String bl) {              // package-private
 394         if (bugLevel == null) {
 395             if (!sun.misc.VM.isBooted())
 396                 return false;
 397             String value = AccessController.doPrivileged(


 312                     } catch (ClassNotFoundException   |
 313                              NoSuchMethodException    |
 314                              IllegalArgumentException |
 315                              ClassCastException x) {
 316                         throw new InternalError(x);
 317                     }
 318                     return null;
 319                 }});
 320     }
 321 
 322     static MappedByteBuffer newMappedByteBuffer(int size, long addr,
 323                                                 FileDescriptor fd,
 324                                                 Runnable unmapper)
 325     {
 326         MappedByteBuffer dbb;
 327         if (directByteBufferConstructor == null)
 328             initDBBConstructor();
 329         try {
 330             dbb = (MappedByteBuffer)directByteBufferConstructor.newInstance(
 331               new Object[] { new Integer(size),
 332                              addr,
 333                              fd,
 334                              unmapper });
 335         } catch (InstantiationException |
 336                  IllegalAccessException |
 337                  InvocationTargetException e) {
 338             throw new InternalError(e);
 339         }
 340         return dbb;
 341     }
 342 
 343     private static volatile Constructor<?> directByteBufferRConstructor = null;
 344 
 345     private static void initDBBRConstructor() {
 346         AccessController.doPrivileged(new PrivilegedAction<Void>() {
 347                 public Void run() {
 348                     try {
 349                         Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
 350                         Constructor<?> ctor = cl.getDeclaredConstructor(
 351                             new Class<?>[] { int.class,
 352                                              long.class,


 357                     } catch (ClassNotFoundException |
 358                              NoSuchMethodException |
 359                              IllegalArgumentException |
 360                              ClassCastException x) {
 361                         throw new InternalError(x);
 362                     }
 363                     return null;
 364                 }});
 365     }
 366 
 367     static MappedByteBuffer newMappedByteBufferR(int size, long addr,
 368                                                  FileDescriptor fd,
 369                                                  Runnable unmapper)
 370     {
 371         MappedByteBuffer dbb;
 372         if (directByteBufferRConstructor == null)
 373             initDBBRConstructor();
 374         try {
 375             dbb = (MappedByteBuffer)directByteBufferRConstructor.newInstance(
 376               new Object[] { new Integer(size),
 377                              addr,
 378                              fd,
 379                              unmapper });
 380         } catch (InstantiationException |
 381                  IllegalAccessException |
 382                  InvocationTargetException e) {
 383             throw new InternalError(e);
 384         }
 385         return dbb;
 386     }
 387 
 388 
 389     // -- Bug compatibility --
 390 
 391     private static volatile String bugLevel = null;
 392 
 393     static boolean atBugLevel(String bl) {              // package-private
 394         if (bugLevel == null) {
 395             if (!sun.misc.VM.isBooted())
 396                 return false;
 397             String value = AccessController.doPrivileged(