|
26 | 26 | import java.lang.invoke.MethodHandle; |
27 | 27 | import java.lang.invoke.MethodHandles; |
28 | 28 | import java.lang.invoke.VarHandle; |
29 | | -import java.security.AccessController; |
30 | | -import java.security.PrivilegedAction; |
31 | 29 | import java.util.Map; |
32 | 30 |
|
33 | 31 | import static java.lang.invoke.MethodType.methodType; |
@@ -91,62 +89,62 @@ private OffHeapReflectionUtils() {} |
91 | 89 | try { |
92 | 90 | // Lucene99ScalarQuantizedVectorsReader |
93 | 91 | var cls = Class.forName("org.apache.lucene.codecs.lucene99.Lucene99ScalarQuantizedVectorsReader$FieldEntry"); |
94 | | - var lookup = privilegedPrivateLookupIn(L99_SQ_VR_CLS, MethodHandles.lookup()); |
| 92 | + var lookup = MethodHandles.privateLookupIn(L99_SQ_VR_CLS, MethodHandles.lookup()); |
95 | 93 | var mt = methodType(cls, String.class); |
96 | 94 | GET_FIELD_ENTRY_HNDL_SQ = lookup.findVirtual(L99_SQ_VR_CLS, "getFieldEntry", mt); |
97 | 95 | GET_VECTOR_DATA_LENGTH_HANDLE_SQ = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
98 | 96 | RAW_VECTORS_READER_HNDL_SQ = lookup.findVarHandle(L99_SQ_VR_CLS, "rawVectorsReader", FlatVectorsReader.class); |
99 | 97 | // Lucene99FlatVectorsReader |
100 | 98 | cls = Class.forName("org.apache.lucene.codecs.lucene99.Lucene99FlatVectorsReader$FieldEntry"); |
101 | | - lookup = privilegedPrivateLookupIn(L99_FLT_VR_CLS, MethodHandles.lookup()); |
| 99 | + lookup = MethodHandles.privateLookupIn(L99_FLT_VR_CLS, MethodHandles.lookup()); |
102 | 100 | mt = methodType(cls, String.class, VectorEncoding.class); |
103 | 101 | GET_FIELD_ENTRY_HANDLE_L99FLT = lookup.findVirtual(L99_FLT_VR_CLS, "getFieldEntry", mt); |
104 | 102 | VECTOR_DATA_LENGTH_HANDLE_L99FLT = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
105 | 103 | // DirectIOLucene99FlatVectorsReader |
106 | 104 | cls = Class.forName("org.elasticsearch.index.codec.vectors.es818.DirectIOLucene99FlatVectorsReader$FieldEntry"); |
107 | | - lookup = privilegedPrivateLookupIn(DIOL99_FLT_VR_CLS, MethodHandles.lookup()); |
| 105 | + lookup = MethodHandles.privateLookupIn(DIOL99_FLT_VR_CLS, MethodHandles.lookup()); |
108 | 106 | mt = methodType(cls, String.class, VectorEncoding.class); |
109 | 107 | GET_FIELD_ENTRY_HANDLE_DIOL99FLT = lookup.findVirtual(DIOL99_FLT_VR_CLS, "getFieldEntry", mt); |
110 | 108 | VECTOR_DATA_LENGTH_HANDLE_DIOL99FLT = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
111 | 109 | // Lucene99HnswVectorsReader |
112 | 110 | cls = Class.forName("org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader$FieldEntry"); |
113 | | - lookup = privilegedPrivateLookupIn(L99_HNSW_VR_CLS, MethodHandles.lookup()); |
| 111 | + lookup = MethodHandles.privateLookupIn(L99_HNSW_VR_CLS, MethodHandles.lookup()); |
114 | 112 | mt = methodType(cls, String.class, VectorEncoding.class); |
115 | 113 | GET_FIELD_ENTRY_HANDLE_L99HNSW = lookup.findVirtual(L99_HNSW_VR_CLS, "getFieldEntry", mt); |
116 | 114 | GET_VECTOR_INDEX_LENGTH_HANDLE_L99HNSW = lookup.findVirtual(cls, "vectorIndexLength", methodType(long.class)); |
117 | | - lookup = privilegedPrivateLookupIn(L99_HNSW_VR_CLS, MethodHandles.lookup()); |
| 115 | + lookup = MethodHandles.privateLookupIn(L99_HNSW_VR_CLS, MethodHandles.lookup()); |
118 | 116 | FLAT_VECTORS_READER_HNDL_L99HNSW = lookup.findVarHandle(L99_HNSW_VR_CLS, "flatVectorsReader", FlatVectorsReader.class); |
119 | 117 | // Lucene90HnswVectorsReader |
120 | 118 | cls = Class.forName("org.apache.lucene.backward_codecs.lucene90.Lucene90HnswVectorsReader$FieldEntry"); |
121 | | - lookup = privilegedPrivateLookupIn(L90_HNSW_VR_CLS, MethodHandles.lookup()); |
| 119 | + lookup = MethodHandles.privateLookupIn(L90_HNSW_VR_CLS, MethodHandles.lookup()); |
122 | 120 | mt = methodType(cls, String.class); |
123 | 121 | GET_FIELD_ENTRY_HANDLE_L90HNSW = lookup.findVirtual(L90_HNSW_VR_CLS, "getFieldEntry", mt); |
124 | 122 | GET_VECTOR_INDEX_LENGTH_HANDLE_L90HNSW = lookup.findVirtual(cls, "indexDataLength", methodType(long.class)); |
125 | 123 | GET_VECTOR_DATA_LENGTH_HANDLE_L90HNSW = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
126 | 124 | // Lucene91HnswVectorsReader |
127 | 125 | cls = Class.forName("org.apache.lucene.backward_codecs.lucene91.Lucene91HnswVectorsReader$FieldEntry"); |
128 | | - lookup = privilegedPrivateLookupIn(L91_HNSW_VR_CLS, MethodHandles.lookup()); |
| 126 | + lookup = MethodHandles.privateLookupIn(L91_HNSW_VR_CLS, MethodHandles.lookup()); |
129 | 127 | mt = methodType(cls, String.class); |
130 | 128 | GET_FIELD_ENTRY_HANDLE_L91HNSW = lookup.findVirtual(L91_HNSW_VR_CLS, "getFieldEntry", mt); |
131 | 129 | GET_VECTOR_INDEX_LENGTH_HANDLE_L91HNSW = lookup.findVirtual(cls, "vectorIndexLength", methodType(long.class)); |
132 | 130 | GET_VECTOR_DATA_LENGTH_HANDLE_L91HNSW = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
133 | 131 | // Lucene92HnswVectorsReader |
134 | 132 | cls = Class.forName("org.apache.lucene.backward_codecs.lucene92.Lucene92HnswVectorsReader$FieldEntry"); |
135 | | - lookup = privilegedPrivateLookupIn(L92_HNSW_VR_CLS, MethodHandles.lookup()); |
| 133 | + lookup = MethodHandles.privateLookupIn(L92_HNSW_VR_CLS, MethodHandles.lookup()); |
136 | 134 | mt = methodType(cls, String.class); |
137 | 135 | GET_FIELD_ENTRY_HANDLE_L92HNSW = lookup.findVirtual(L92_HNSW_VR_CLS, "getFieldEntry", mt); |
138 | 136 | GET_VECTOR_INDEX_LENGTH_HANDLE_L92HNSW = lookup.findVirtual(cls, "vectorIndexLength", methodType(long.class)); |
139 | 137 | GET_VECTOR_DATA_LENGTH_HANDLE_L92HNSW = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
140 | 138 | // Lucene94HnswVectorsReader |
141 | 139 | cls = Class.forName("org.apache.lucene.backward_codecs.lucene94.Lucene94HnswVectorsReader$FieldEntry"); |
142 | | - lookup = privilegedPrivateLookupIn(L94_HNSW_VR_CLS, MethodHandles.lookup()); |
| 140 | + lookup = MethodHandles.privateLookupIn(L94_HNSW_VR_CLS, MethodHandles.lookup()); |
143 | 141 | mt = methodType(cls, String.class, VectorEncoding.class); |
144 | 142 | GET_FIELD_ENTRY_HANDLE_L94HNSW = lookup.findVirtual(L94_HNSW_VR_CLS, "getFieldEntry", mt); |
145 | 143 | GET_VECTOR_INDEX_LENGTH_HANDLE_L94HNSW = lookup.findVirtual(cls, "vectorIndexLength", methodType(long.class)); |
146 | 144 | GET_VECTOR_DATA_LENGTH_HANDLE_L94HNSW = lookup.findVirtual(cls, "vectorDataLength", methodType(long.class)); |
147 | 145 | // Lucene95HnswVectorsReader |
148 | 146 | cls = Class.forName("org.apache.lucene.backward_codecs.lucene95.Lucene95HnswVectorsReader$FieldEntry"); |
149 | | - lookup = privilegedPrivateLookupIn(L95_HNSW_VR_CLS, MethodHandles.lookup()); |
| 147 | + lookup = MethodHandles.privateLookupIn(L95_HNSW_VR_CLS, MethodHandles.lookup()); |
150 | 148 | mt = methodType(cls, String.class, VectorEncoding.class); |
151 | 149 | GET_FIELD_ENTRY_HANDLE_L95HNSW = lookup.findVirtual(L95_HNSW_VR_CLS, "getFieldEntry", mt); |
152 | 150 | GET_VECTOR_INDEX_LENGTH_HANDLE_L95HNSW = lookup.findVirtual(cls, "vectorIndexLength", methodType(long.class)); |
@@ -278,18 +276,6 @@ static Map<String, Long> getOffHeapByteSizeL95HNSW(Lucene95HnswVectorsReader rea |
278 | 276 | throw new AssertionError("should not reach here"); |
279 | 277 | } |
280 | 278 |
|
281 | | - @SuppressWarnings("removal") |
282 | | - private static MethodHandles.Lookup privilegedPrivateLookupIn(Class<?> cls, MethodHandles.Lookup lookup) { |
283 | | - PrivilegedAction<MethodHandles.Lookup> pa = () -> { |
284 | | - try { |
285 | | - return MethodHandles.privateLookupIn(cls, lookup); |
286 | | - } catch (IllegalAccessException e) { |
287 | | - throw new AssertionError("should not happen, check opens", e); |
288 | | - } |
289 | | - }; |
290 | | - return AccessController.doPrivileged(pa); |
291 | | - } |
292 | | - |
293 | 279 | private static void handleThrowable(Throwable t) { |
294 | 280 | if (t instanceof Error error) { |
295 | 281 | throw error; |
|
0 commit comments