@@ -722,8 +722,15 @@ private static int classIndex(Class<?> cl) {
722722 private static final int [] PREPEND_FILTER_SECOND_PAIR_ARGS = new int [] { 0 , 1 , 4 , 5 };
723723
724724 // Base MH for complex prepender combinators.
725- private static final MethodHandle PREPEND_BASE = MethodHandles .dropArguments (
726- MethodHandles .identity (long .class ), 1 , byte [].class );
725+ private static @ Stable MethodHandle PREPEND_BASE ;
726+ private static MethodHandle prependBase () {
727+ MethodHandle base = PREPEND_BASE ;
728+ if (base == null ) {
729+ base = PREPEND_BASE = MethodHandles .dropArguments (
730+ MethodHandles .identity (long .class ), 1 , byte [].class );
731+ }
732+ return base ;
733+ }
727734
728735 private static final @ Stable MethodHandle [][] DOUBLE_PREPENDERS = new MethodHandle [TYPE_COUNT ][TYPE_COUNT ];
729736
@@ -733,7 +740,7 @@ private static MethodHandle prepender(String prefix, Class<?> cl, String prefix2
733740 MethodHandle prepend = DOUBLE_PREPENDERS [idx1 ][idx2 ];
734741 if (prepend == null ) {
735742 prepend = DOUBLE_PREPENDERS [idx1 ][idx2 ] =
736- MethodHandles .dropArguments (PREPEND_BASE , 2 , cl , cl2 );
743+ MethodHandles .dropArguments (prependBase () , 2 , cl , cl2 );
737744 }
738745 prepend = MethodHandles .filterArgumentsWithCombiner (prepend , 0 , prepender (prefix , cl ),
739746 PREPEND_FILTER_FIRST_ARGS );
@@ -750,7 +757,7 @@ private static MethodHandle prepender(int pos, String[] constants, Class<?>[] pt
750757 return prepender (constants [pos ], ptypes [pos ], constants [pos + 1 ], ptypes [pos + 1 ]);
751758 }
752759 // build a tree from an unbound prepender, allowing us to bind the constants in a batch as a final step
753- MethodHandle prepend = PREPEND_BASE ;
760+ MethodHandle prepend = prependBase () ;
754761 if (count == 3 ) {
755762 prepend = MethodHandles .dropArguments (prepend , 2 ,
756763 ptypes [pos ], ptypes [pos + 1 ], ptypes [pos + 2 ]);
0 commit comments