equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
413 Class<?> cl = Class.forName("java.nio.DirectByteBuffer"); |
413 Class<?> cl = Class.forName("java.nio.DirectByteBuffer"); |
414 Constructor<?> ctor = cl.getDeclaredConstructor( |
414 Constructor<?> ctor = cl.getDeclaredConstructor( |
415 new Class<?>[] { int.class, |
415 new Class<?>[] { int.class, |
416 long.class, |
416 long.class, |
417 FileDescriptor.class, |
417 FileDescriptor.class, |
418 Runnable.class }); |
418 Runnable.class, |
|
419 boolean.class }); |
419 ctor.setAccessible(true); |
420 ctor.setAccessible(true); |
420 directByteBufferConstructor = ctor; |
421 directByteBufferConstructor = ctor; |
421 } catch (ClassNotFoundException | |
422 } catch (ClassNotFoundException | |
422 NoSuchMethodException | |
423 NoSuchMethodException | |
423 IllegalArgumentException | |
424 IllegalArgumentException | |
428 }}); |
429 }}); |
429 } |
430 } |
430 |
431 |
431 static MappedByteBuffer newMappedByteBuffer(int size, long addr, |
432 static MappedByteBuffer newMappedByteBuffer(int size, long addr, |
432 FileDescriptor fd, |
433 FileDescriptor fd, |
433 Runnable unmapper) |
434 Runnable unmapper, |
|
435 boolean isSync) |
434 { |
436 { |
435 MappedByteBuffer dbb; |
437 MappedByteBuffer dbb; |
436 if (directByteBufferConstructor == null) |
438 if (directByteBufferConstructor == null) |
437 initDBBConstructor(); |
439 initDBBConstructor(); |
438 try { |
440 try { |
439 dbb = (MappedByteBuffer)directByteBufferConstructor.newInstance( |
441 dbb = (MappedByteBuffer)directByteBufferConstructor.newInstance( |
440 new Object[] { size, |
442 new Object[] { size, |
441 addr, |
443 addr, |
442 fd, |
444 fd, |
443 unmapper }); |
445 unmapper, |
|
446 isSync}); |
444 } catch (InstantiationException | |
447 } catch (InstantiationException | |
445 IllegalAccessException | |
448 IllegalAccessException | |
446 InvocationTargetException e) { |
449 InvocationTargetException e) { |
447 throw new InternalError(e); |
450 throw new InternalError(e); |
448 } |
451 } |
458 Class<?> cl = Class.forName("java.nio.DirectByteBufferR"); |
461 Class<?> cl = Class.forName("java.nio.DirectByteBufferR"); |
459 Constructor<?> ctor = cl.getDeclaredConstructor( |
462 Constructor<?> ctor = cl.getDeclaredConstructor( |
460 new Class<?>[] { int.class, |
463 new Class<?>[] { int.class, |
461 long.class, |
464 long.class, |
462 FileDescriptor.class, |
465 FileDescriptor.class, |
463 Runnable.class }); |
466 Runnable.class, |
|
467 boolean.class }); |
464 ctor.setAccessible(true); |
468 ctor.setAccessible(true); |
465 directByteBufferRConstructor = ctor; |
469 directByteBufferRConstructor = ctor; |
466 } catch (ClassNotFoundException | |
470 } catch (ClassNotFoundException | |
467 NoSuchMethodException | |
471 NoSuchMethodException | |
468 IllegalArgumentException | |
472 IllegalArgumentException | |
473 }}); |
477 }}); |
474 } |
478 } |
475 |
479 |
476 static MappedByteBuffer newMappedByteBufferR(int size, long addr, |
480 static MappedByteBuffer newMappedByteBufferR(int size, long addr, |
477 FileDescriptor fd, |
481 FileDescriptor fd, |
478 Runnable unmapper) |
482 Runnable unmapper, |
|
483 boolean isSync) |
479 { |
484 { |
480 MappedByteBuffer dbb; |
485 MappedByteBuffer dbb; |
481 if (directByteBufferRConstructor == null) |
486 if (directByteBufferRConstructor == null) |
482 initDBBRConstructor(); |
487 initDBBRConstructor(); |
483 try { |
488 try { |
484 dbb = (MappedByteBuffer)directByteBufferRConstructor.newInstance( |
489 dbb = (MappedByteBuffer)directByteBufferRConstructor.newInstance( |
485 new Object[] { size, |
490 new Object[] { size, |
486 addr, |
491 addr, |
487 fd, |
492 fd, |
488 unmapper }); |
493 unmapper, |
|
494 isSync}); |
489 } catch (InstantiationException | |
495 } catch (InstantiationException | |
490 IllegalAccessException | |
496 IllegalAccessException | |
491 InvocationTargetException e) { |
497 InvocationTargetException e) { |
492 throw new InternalError(e); |
498 throw new InternalError(e); |
493 } |
499 } |