1 /*
2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
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
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */

25
26 // -- This file was mechanically generated: Do not edit! -- //
27
28 package java.nio;
29
30 import java.io.FileDescriptor;
31 import java.lang.ref.Reference;
32 import jdk.internal.misc.VM;
33 import jdk.internal.ref.Cleaner;
34 import sun.nio.ch.DirectBuffer;
35
36
37 class DirectByteBufferR
38
39
40
41     extends DirectByteBuffer
42
43     implements DirectBuffer
44 {
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110     // Primary constructor
111     //
112     DirectByteBufferR(int cap) {                   // package-private
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137         super(cap);
138         this.isReadOnly = true;
139
140     }
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166     // For memory-mapped buffers -- invoked by FileChannelImpl via reflection
167     //
168     protected DirectByteBufferR(int cap, long addr,
169                                      FileDescriptor fd,
170                                      Runnable unmapper)
171     {
172
173
174
175
176
177
178         super(cap, addr, fd, unmapper);
179         this.isReadOnly = true;
180
181     }
182
183
184
185     // For duplicates and slices
186     //
187     DirectByteBufferR(DirectBuffer db,         // package-private
188                                int mark, int pos, int lim, int cap,
189                                int off)
190     {
191
192
193
194
195
196
197
198
199         super(db, mark, pos, lim, cap, off);
200         this.isReadOnly = true;
201
202     }
203
204     @Override
205     Object base() {
206         return null;
207     }
208
209     public ByteBuffer slice() {
210         int pos = this.position();
211         int lim = this.limit();
212         assert (pos <= lim);
213         int rem = (pos <= lim ? lim - pos : 0);
214         int off = (pos << 0);
215         assert (off >= 0);
216         return new DirectByteBufferR(this, -1, 0, rem, rem, off);
217     }
218
219
220     public ByteBuffer slice(int pos, int lim) {
221         assert (pos >= 0);
222         assert (pos <= lim);
223         int rem = lim - pos;
224         return new DirectByteBufferR(this, -1, 0, rem, rem, pos);
225     }
226
227
228     public ByteBuffer duplicate() {
229         return new DirectByteBufferR(this,
230                                               this.markValue(),
231                                               this.position(),
232                                               this.limit(),
233                                               this.capacity(),
234                                               0);
235     }
236
237     public ByteBuffer asReadOnlyBuffer() {
238
239
240
241
242
243
244
245
246         return duplicate();
247
248     }
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329     public ByteBuffer put(byte x) {
330
331
332
333
334
335
336
337
338         throw new ReadOnlyBufferException();
339
340     }
341
342     public ByteBuffer put(int i, byte x) {
343
344
345
346
347
348
349
350
351         throw new ReadOnlyBufferException();
352
353     }
354
355     public ByteBuffer put(ByteBuffer src) {
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397         throw new ReadOnlyBufferException();
398
399     }
400
401     public ByteBuffer put(byte[] src, int offset, int length) {
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438         throw new ReadOnlyBufferException();
439
440     }
441
442     public ByteBuffer compact() {
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458         throw new ReadOnlyBufferException();
459
460     }
461
462     public boolean isDirect() {
463         return true;
464     }
465
466     public boolean isReadOnly() {
467         return true;
468     }
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567     private ByteBuffer putChar(long a, char x) {
568
569
570
571
572
573
574
575
576
577         throw new ReadOnlyBufferException();
578
579     }
580
581     public ByteBuffer putChar(char x) {
582
583
584
585
586         throw new ReadOnlyBufferException();
587
588     }
589
590     public ByteBuffer putChar(int i, char x) {
591
592
593
594
595         throw new ReadOnlyBufferException();
596
597     }
598
599     public CharBuffer asCharBuffer() {
600         int off = this.position();
601         int lim = this.limit();
602         assert (off <= lim);
603         int rem = (off <= lim ? lim - off : 0);
604
605         int size = rem >> 1;
606         if (!UNALIGNED && ((address + off) % (1 << 1) != 0)) {
607             return (bigEndian
608                     ? (CharBuffer)(new ByteBufferAsCharBufferRB(this,
609                                                                        -1,
610                                                                        0,
611                                                                        size,
612                                                                        size,
613                                                                        address + off))
614                     : (CharBuffer)(new ByteBufferAsCharBufferRL(this,
615                                                                        -1,
616                                                                        0,
617                                                                        size,
618                                                                        size,
619                                                                        address + off)));
620         } else {
621             return (nativeByteOrder
622                     ? (CharBuffer)(new DirectCharBufferRU(this,
623                                                                  -1,
624                                                                  0,
625                                                                  size,
626                                                                  size,
627                                                                  off))
628                     : (CharBuffer)(new DirectCharBufferRS(this,
629                                                                  -1,
630                                                                  0,
631                                                                  size,
632                                                                  size,
633                                                                  off)));
634         }
635     }
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667     private ByteBuffer putShort(long a, short x) {
668
669
670
671
672
673
674
675
676
677         throw new ReadOnlyBufferException();
678
679     }
680
681     public ByteBuffer putShort(short x) {
682
683
684
685
686         throw new ReadOnlyBufferException();
687
688     }
689
690     public ByteBuffer putShort(int i, short x) {
691
692
693
694
695         throw new ReadOnlyBufferException();
696
697     }
698
699     public ShortBuffer asShortBuffer() {
700         int off = this.position();
701         int lim = this.limit();
702         assert (off <= lim);
703         int rem = (off <= lim ? lim - off : 0);
704
705         int size = rem >> 1;
706         if (!UNALIGNED && ((address + off) % (1 << 1) != 0)) {
707             return (bigEndian
708                     ? (ShortBuffer)(new ByteBufferAsShortBufferRB(this,
709                                                                        -1,
710                                                                        0,
711                                                                        size,
712                                                                        size,
713                                                                        address + off))
714                     : (ShortBuffer)(new ByteBufferAsShortBufferRL(this,
715                                                                        -1,
716                                                                        0,
717                                                                        size,
718                                                                        size,
719                                                                        address + off)));
720         } else {
721             return (nativeByteOrder
722                     ? (ShortBuffer)(new DirectShortBufferRU(this,
723                                                                  -1,
724                                                                  0,
725                                                                  size,
726                                                                  size,
727                                                                  off))
728                     : (ShortBuffer)(new DirectShortBufferRS(this,
729                                                                  -1,
730                                                                  0,
731                                                                  size,
732                                                                  size,
733                                                                  off)));
734         }
735     }
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767     private ByteBuffer putInt(long a, int x) {
768
769
770
771
772
773
774
775
776
777         throw new ReadOnlyBufferException();
778
779     }
780
781     public ByteBuffer putInt(int x) {
782
783
784
785
786         throw new ReadOnlyBufferException();
787
788     }
789
790     public ByteBuffer putInt(int i, int x) {
791
792
793
794
795         throw new ReadOnlyBufferException();
796
797     }
798
799     public IntBuffer asIntBuffer() {
800         int off = this.position();
801         int lim = this.limit();
802         assert (off <= lim);
803         int rem = (off <= lim ? lim - off : 0);
804
805         int size = rem >> 2;
806         if (!UNALIGNED && ((address + off) % (1 << 2) != 0)) {
807             return (bigEndian
808                     ? (IntBuffer)(new ByteBufferAsIntBufferRB(this,
809                                                                        -1,
810                                                                        0,
811                                                                        size,
812                                                                        size,
813                                                                        address + off))
814                     : (IntBuffer)(new ByteBufferAsIntBufferRL(this,
815                                                                        -1,
816                                                                        0,
817                                                                        size,
818                                                                        size,
819                                                                        address + off)));
820         } else {
821             return (nativeByteOrder
822                     ? (IntBuffer)(new DirectIntBufferRU(this,
823                                                                  -1,
824                                                                  0,
825                                                                  size,
826                                                                  size,
827                                                                  off))
828                     : (IntBuffer)(new DirectIntBufferRS(this,
829                                                                  -1,
830                                                                  0,
831                                                                  size,
832                                                                  size,
833                                                                  off)));
834         }
835     }
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867     private ByteBuffer putLong(long a, long x) {
868
869
870
871
872
873
874
875
876
877         throw new ReadOnlyBufferException();
878
879     }
880
881     public ByteBuffer putLong(long x) {
882
883
884
885
886         throw new ReadOnlyBufferException();
887
888     }
889
890     public ByteBuffer putLong(int i, long x) {
891
892
893
894
895         throw new ReadOnlyBufferException();
896
897     }
898
899     public LongBuffer asLongBuffer() {
900         int off = this.position();
901         int lim = this.limit();
902         assert (off <= lim);
903         int rem = (off <= lim ? lim - off : 0);
904
905         int size = rem >> 3;
906         if (!UNALIGNED && ((address + off) % (1 << 3) != 0)) {
907             return (bigEndian
908                     ? (LongBuffer)(new ByteBufferAsLongBufferRB(this,
909                                                                        -1,
910                                                                        0,
911                                                                        size,
912                                                                        size,
913                                                                        address + off))
914                     : (LongBuffer)(new ByteBufferAsLongBufferRL(this,
915                                                                        -1,
916                                                                        0,
917                                                                        size,
918                                                                        size,
919                                                                        address + off)));
920         } else {
921             return (nativeByteOrder
922                     ? (LongBuffer)(new DirectLongBufferRU(this,
923                                                                  -1,
924                                                                  0,
925                                                                  size,
926                                                                  size,
927                                                                  off))
928                     : (LongBuffer)(new DirectLongBufferRS(this,
929                                                                  -1,
930                                                                  0,
931                                                                  size,
932                                                                  size,
933                                                                  off)));
934         }
935     }
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967     private ByteBuffer putFloat(long a, float x) {
968
969
970
971
972
973
974
975
976
977         throw new ReadOnlyBufferException();
978
979     }
980
981     public ByteBuffer putFloat(float x) {
982
983
984
985
986         throw new ReadOnlyBufferException();
987
988     }
989
990     public ByteBuffer putFloat(int i, float x) {
991
992
993
994
995         throw new ReadOnlyBufferException();
996
997     }
998
999     public FloatBuffer asFloatBuffer() {
1000         int off = this.position();
1001         int lim = this.limit();
1002         assert (off <= lim);
1003         int rem = (off <= lim ? lim - off : 0);
1004
1005         int size = rem >> 2;
1006         if (!UNALIGNED && ((address + off) % (1 << 2) != 0)) {
1007             return (bigEndian
1008                     ? (FloatBuffer)(new ByteBufferAsFloatBufferRB(this,
1009                                                                        -1,
1010                                                                        0,
1011                                                                        size,
1012                                                                        size,
1013                                                                        address + off))
1014                     : (FloatBuffer)(new ByteBufferAsFloatBufferRL(this,
1015                                                                        -1,
1016                                                                        0,
1017                                                                        size,
1018                                                                        size,
1019                                                                        address + off)));
1020         } else {
1021             return (nativeByteOrder
1022                     ? (FloatBuffer)(new DirectFloatBufferRU(this,
1023                                                                  -1,
1024                                                                  0,
1025                                                                  size,
1026                                                                  size,
1027                                                                  off))
1028                     : (FloatBuffer)(new DirectFloatBufferRS(this,
1029                                                                  -1,
1030                                                                  0,
1031                                                                  size,
1032                                                                  size,
1033                                                                  off)));
1034         }
1035     }
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067     private ByteBuffer putDouble(long a, double x) {
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077         throw new ReadOnlyBufferException();
1078
1079     }
1080
1081     public ByteBuffer putDouble(double x) {
1082
1083
1084
1085
1086         throw new ReadOnlyBufferException();
1087
1088     }
1089
1090     public ByteBuffer putDouble(int i, double x) {
1091
1092
1093
1094
1095         throw new ReadOnlyBufferException();
1096
1097     }
1098
1099     public DoubleBuffer asDoubleBuffer() {
1100         int off = this.position();
1101         int lim = this.limit();
1102         assert (off <= lim);
1103         int rem = (off <= lim ? lim - off : 0);
1104
1105         int size = rem >> 3;
1106         if (!UNALIGNED && ((address + off) % (1 << 3) != 0)) {
1107             return (bigEndian
1108                     ? (DoubleBuffer)(new ByteBufferAsDoubleBufferRB(this,
1109                                                                        -1,
1110                                                                        0,
1111                                                                        size,
1112                                                                        size,
1113                                                                        address + off))
1114                     : (DoubleBuffer)(new ByteBufferAsDoubleBufferRL(this,
1115                                                                        -1,
1116                                                                        0,
1117                                                                        size,
1118                                                                        size,
1119                                                                        address + off)));
1120         } else {
1121             return (nativeByteOrder
1122                     ? (DoubleBuffer)(new DirectDoubleBufferRU(this,
1123                                                                  -1,
1124                                                                  0,
1125                                                                  size,
1126                                                                  size,
1127                                                                  off))
1128                     : (DoubleBuffer)(new DirectDoubleBufferRS(this,
1129                                                                  -1,
1130                                                                  0,
1131                                                                  size,
1132                                                                  size,
1133                                                                  off)));
1134         }
1135     }
1136
1137 }
1138