author | kvn |
Thu, 31 Mar 2016 09:16:49 -0700 | |
changeset 37276 | f61297514617 |
parent 34549 | 412a690d4414 |
child 41422 | 97eda72f53b6 |
permissions | -rw-r--r-- |
34548
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
1 |
/* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
3 |
* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
4 |
* Redistribution and use in source and binary forms, with or without |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
5 |
* modification, are permitted provided that the following conditions |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
6 |
* are met: |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
7 |
* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
8 |
* - Redistributions of source code must retain the above copyright |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
9 |
* notice, this list of conditions and the following disclaimer. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
10 |
* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
11 |
* - Redistributions in binary form must reproduce the above copyright |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
12 |
* notice, this list of conditions and the following disclaimer in the |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
13 |
* documentation and/or other materials provided with the distribution. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
14 |
* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
15 |
* - Neither the name of Oracle nor the names of its |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
16 |
* contributors may be used to endorse or promote products derived |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
17 |
* from this software without specific prior written permission. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
18 |
* |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
19 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
20 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
21 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
22 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
23 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
24 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
25 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
26 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
27 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
28 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
29 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
30 |
*/ |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
31 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
32 |
import java.lang.invoke.MethodHandle; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
33 |
import java.lang.invoke.MethodHandles; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
34 |
import java.lang.invoke.MethodType; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
35 |
import java.util.ArrayList; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
36 |
import java.util.List; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
37 |
import java.nio.Buffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
38 |
import java.nio.ByteBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
39 |
import java.nio.CharBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
40 |
import java.nio.DoubleBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
41 |
import java.nio.FloatBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
42 |
import java.nio.IntBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
43 |
import java.nio.LongBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
44 |
import java.nio.ShortBuffer; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
45 |
import jdk.dynalink.CallSiteDescriptor; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
46 |
import jdk.dynalink.CompositeOperation; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
47 |
import jdk.dynalink.NamedOperation; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
48 |
import jdk.dynalink.Operation; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
49 |
import jdk.dynalink.StandardOperation; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
50 |
import jdk.dynalink.linker.GuardingDynamicLinker; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
51 |
import jdk.dynalink.linker.GuardingDynamicLinkerExporter; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
52 |
import jdk.dynalink.linker.GuardedInvocation; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
53 |
import jdk.dynalink.linker.TypeBasedGuardingDynamicLinker; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
54 |
import jdk.dynalink.linker.LinkRequest; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
55 |
import jdk.dynalink.linker.LinkerServices; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
56 |
import jdk.dynalink.linker.support.Guards; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
57 |
import jdk.dynalink.linker.support.Lookup; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
58 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
59 |
/** |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
60 |
* This is a dynalink pluggable linker (see http://openjdk.java.net/jeps/276). |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
61 |
* This linker adds array-like indexing and "length" property to nio Buffer objects. |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
62 |
*/ |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
63 |
public final class BufferIndexingLinkerExporter extends GuardingDynamicLinkerExporter { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
64 |
static { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
65 |
System.out.println("pluggable dynalink buffer indexing linker loaded"); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
66 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
67 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
68 |
private static final MethodHandle BUFFER_LIMIT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
69 |
private static final MethodHandle BYTEBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
70 |
private static final MethodHandle BYTEBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
71 |
private static final MethodHandle CHARBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
72 |
private static final MethodHandle CHARBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
73 |
private static final MethodHandle SHORTBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
74 |
private static final MethodHandle SHORTBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
75 |
private static final MethodHandle INTBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
76 |
private static final MethodHandle INTBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
77 |
private static final MethodHandle LONGBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
78 |
private static final MethodHandle LONGBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
79 |
private static final MethodHandle FLOATBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
80 |
private static final MethodHandle FLOATBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
81 |
private static final MethodHandle DOUBLEBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
82 |
private static final MethodHandle DOUBLEBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
83 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
84 |
// guards |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
85 |
private static final MethodHandle IS_BUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
86 |
private static final MethodHandle IS_BYTEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
87 |
private static final MethodHandle IS_CHARBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
88 |
private static final MethodHandle IS_SHORTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
89 |
private static final MethodHandle IS_INTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
90 |
private static final MethodHandle IS_LONGBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
91 |
private static final MethodHandle IS_FLOATBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
92 |
private static final MethodHandle IS_DOUBLEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
93 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
94 |
private static final MethodType GUARD_TYPE; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
95 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
96 |
static { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
97 |
Lookup look = Lookup.PUBLIC; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
98 |
BUFFER_LIMIT = look.findVirtual(Buffer.class, "limit", MethodType.methodType(int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
99 |
BYTEBUFFER_GET = look.findVirtual(ByteBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
100 |
MethodType.methodType(byte.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
101 |
BYTEBUFFER_PUT = look.findVirtual(ByteBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
102 |
MethodType.methodType(ByteBuffer.class, int.class, byte.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
103 |
CHARBUFFER_GET = look.findVirtual(CharBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
104 |
MethodType.methodType(char.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
105 |
CHARBUFFER_PUT = look.findVirtual(CharBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
106 |
MethodType.methodType(CharBuffer.class, int.class, char.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
107 |
SHORTBUFFER_GET = look.findVirtual(ShortBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
108 |
MethodType.methodType(short.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
109 |
SHORTBUFFER_PUT = look.findVirtual(ShortBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
110 |
MethodType.methodType(ShortBuffer.class, int.class, short.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
111 |
INTBUFFER_GET = look.findVirtual(IntBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
112 |
MethodType.methodType(int.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
113 |
INTBUFFER_PUT = look.findVirtual(IntBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
114 |
MethodType.methodType(IntBuffer.class, int.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
115 |
LONGBUFFER_GET = look.findVirtual(LongBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
116 |
MethodType.methodType(long.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
117 |
LONGBUFFER_PUT = look.findVirtual(LongBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
118 |
MethodType.methodType(LongBuffer.class, int.class, long.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
119 |
FLOATBUFFER_GET = look.findVirtual(FloatBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
120 |
MethodType.methodType(float.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
121 |
FLOATBUFFER_PUT = look.findVirtual(FloatBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
122 |
MethodType.methodType(FloatBuffer.class, int.class, float.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
123 |
DOUBLEBUFFER_GET = look.findVirtual(DoubleBuffer.class, "get", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
124 |
MethodType.methodType(double.class, int.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
125 |
DOUBLEBUFFER_PUT = look.findVirtual(DoubleBuffer.class, "put", |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
126 |
MethodType.methodType(DoubleBuffer.class, int.class, double.class)); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
127 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
128 |
GUARD_TYPE = MethodType.methodType(boolean.class, Object.class); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
129 |
IS_BUFFER = Guards.isInstance(Buffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
130 |
IS_BYTEBUFFER = Guards.isInstance(ByteBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
131 |
IS_CHARBUFFER = Guards.isInstance(CharBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
132 |
IS_SHORTBUFFER = Guards.isInstance(ShortBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
133 |
IS_INTBUFFER = Guards.isInstance(IntBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
134 |
IS_LONGBUFFER = Guards.isInstance(LongBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
135 |
IS_FLOATBUFFER = Guards.isInstance(FloatBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
136 |
IS_DOUBLEBUFFER = Guards.isInstance(DoubleBuffer.class, GUARD_TYPE); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
137 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
138 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
139 |
// locate the first standard operation from the call descriptor |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
140 |
private static StandardOperation getFirstStandardOperation(final CallSiteDescriptor desc) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
141 |
final Operation base = NamedOperation.getBaseOperation(desc.getOperation()); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
142 |
if (base instanceof StandardOperation) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
143 |
return (StandardOperation)base; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
144 |
} else if (base instanceof CompositeOperation) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
145 |
final CompositeOperation cop = (CompositeOperation)base; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
146 |
for(int i = 0; i < cop.getOperationCount(); ++i) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
147 |
final Operation op = cop.getOperation(i); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
148 |
if (op instanceof StandardOperation) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
149 |
return (StandardOperation)op; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
150 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
151 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
152 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
153 |
return null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
154 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
155 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
156 |
@Override |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
157 |
public List<GuardingDynamicLinker> get() { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
158 |
final ArrayList<GuardingDynamicLinker> linkers = new ArrayList<>(); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
159 |
linkers.add(new TypeBasedGuardingDynamicLinker() { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
160 |
@Override |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
161 |
public boolean canLinkType(final Class<?> type) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
162 |
return Buffer.class.isAssignableFrom(type); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
163 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
164 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
165 |
@Override |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
166 |
public GuardedInvocation getGuardedInvocation(LinkRequest request, |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
167 |
LinkerServices linkerServices) throws Exception { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
168 |
final Object self = request.getReceiver(); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
169 |
if (self == null || !canLinkType(self.getClass())) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
170 |
return null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
171 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
172 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
173 |
CallSiteDescriptor desc = request.getCallSiteDescriptor(); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
174 |
StandardOperation op = getFirstStandardOperation(desc); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
175 |
if (op == null) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
176 |
return null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
177 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
178 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
179 |
switch (op) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
180 |
case GET_ELEMENT: |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
181 |
return linkGetElement(self); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
182 |
case SET_ELEMENT: |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
183 |
return linkSetElement(self); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
184 |
case GET_PROPERTY: { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
185 |
Object name = NamedOperation.getName(desc.getOperation()); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
186 |
if ("length".equals(name)) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
187 |
return linkLength(); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
188 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
189 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
190 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
191 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
192 |
return null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
193 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
194 |
}); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
195 |
return linkers; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
196 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
197 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
198 |
private static GuardedInvocation linkGetElement(Object self) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
199 |
MethodHandle method = null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
200 |
MethodHandle guard = null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
201 |
if (self instanceof ByteBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
202 |
method = BYTEBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
203 |
guard = IS_BYTEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
204 |
} else if (self instanceof CharBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
205 |
method = CHARBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
206 |
guard = IS_CHARBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
207 |
} else if (self instanceof ShortBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
208 |
method = SHORTBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
209 |
guard = IS_SHORTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
210 |
} else if (self instanceof IntBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
211 |
method = INTBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
212 |
guard = IS_INTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
213 |
} else if (self instanceof LongBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
214 |
method = LONGBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
215 |
guard = IS_LONGBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
216 |
} else if (self instanceof FloatBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
217 |
method = FLOATBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
218 |
guard = IS_FLOATBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
219 |
} else if (self instanceof DoubleBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
220 |
method = DOUBLEBUFFER_GET; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
221 |
guard = IS_DOUBLEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
222 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
223 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
224 |
return method != null? new GuardedInvocation(method, guard) : null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
225 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
226 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
227 |
private static GuardedInvocation linkSetElement(Object self) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
228 |
MethodHandle method = null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
229 |
MethodHandle guard = null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
230 |
if (self instanceof ByteBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
231 |
method = BYTEBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
232 |
guard = IS_BYTEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
233 |
} else if (self instanceof CharBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
234 |
method = CHARBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
235 |
guard = IS_CHARBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
236 |
} else if (self instanceof ShortBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
237 |
method = SHORTBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
238 |
guard = IS_SHORTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
239 |
} else if (self instanceof IntBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
240 |
method = INTBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
241 |
guard = IS_INTBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
242 |
} else if (self instanceof LongBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
243 |
method = LONGBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
244 |
guard = IS_LONGBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
245 |
} else if (self instanceof FloatBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
246 |
method = FLOATBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
247 |
guard = IS_FLOATBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
248 |
} else if (self instanceof DoubleBuffer) { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
249 |
method = DOUBLEBUFFER_PUT; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
250 |
guard = IS_DOUBLEBUFFER; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
251 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
252 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
253 |
return method != null? new GuardedInvocation(method, guard) : null; |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
254 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
255 |
|
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
256 |
private static GuardedInvocation linkLength() { |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
257 |
return new GuardedInvocation(BUFFER_LIMIT, IS_BUFFER); |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
258 |
} |
44779bfb4c13
8144841: Add a sample for pluggable dynalink linker for stream property on arrays and a REAMDE for linker samples
sundar
parents:
diff
changeset
|
259 |
} |