Path: blob/master/test/hotspot/jtreg/compiler/patches/java.base/java/lang/Helper.java
41161 views
/*1* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223package java.lang;2425/**26* A helper class to get access to package-private members27*/28public class Helper {29@jdk.internal.vm.annotation.ForceInline30public static boolean StringCodingHasNegatives(byte[] ba, int off, int len) {31return StringCoding.hasNegatives(ba, off, len);32}3334@jdk.internal.vm.annotation.ForceInline35public static byte[] compressByte(byte[] src, int srcOff, int dstSize, int dstOff, int len) {36byte[] dst = new byte[dstSize];37StringUTF16.compress(src, srcOff, dst, dstOff, len);38return dst;39}4041@jdk.internal.vm.annotation.ForceInline42public static byte[] compressChar(char[] src, int srcOff, int dstSize, int dstOff, int len) {43byte[] dst = new byte[dstSize];44StringUTF16.compress(src, srcOff, dst, dstOff, len);45return dst;46}4748@jdk.internal.vm.annotation.ForceInline49public static byte[] inflateByte(byte[] src, int srcOff, int dstSize, int dstOff, int len) {50byte[] dst = new byte[dstSize];51StringLatin1.inflate(src, srcOff, dst, dstOff, len);52return dst;53}5455@jdk.internal.vm.annotation.ForceInline56public static char[] inflateChar(byte[] src, int srcOff, int dstSize, int dstOff, int len) {57char[] dst = new char[dstSize];58StringLatin1.inflate(src, srcOff, dst, dstOff, len);59return dst;60}6162@jdk.internal.vm.annotation.ForceInline63public static byte[] toBytes(char[] value, int off, int len) {64return StringUTF16.toBytes(value, off, len);65}6667@jdk.internal.vm.annotation.ForceInline68public static char[] getChars(byte[] value, int srcBegin, int srcEnd, int dstSize, int dstBegin) {69char[] dst = new char[dstSize];70StringUTF16.getChars(value, srcBegin, srcEnd, dst, dstBegin);71return dst;72}7374public static void putCharSB(byte[] val, int index, int c) {75StringUTF16.putCharSB(val, index, c);76}7778public static void putCharsSB(byte[] val, int index, char[] ca, int off, int end) {79StringUTF16.putCharsSB(val, index, ca, off, end);80}8182public static void putCharsSB(byte[] val, int index, CharSequence s, int off, int end) {83StringUTF16.putCharsSB(val, index, s, off, end);84}8586public static int codePointAtSB(byte[] val, int index, int end) {87return StringUTF16.codePointAtSB(val, index, end);88}8990public static int codePointBeforeSB(byte[] val, int index) {91return StringUTF16.codePointBeforeSB(val, index);92}9394public static int codePointCountSB(byte[] val, int beginIndex, int endIndex) {95return StringUTF16.codePointCountSB(val, beginIndex, endIndex);96}9798public static int getChars(int i, int begin, int end, byte[] value) {99return StringUTF16.getChars(i, begin, end, value);100}101102public static int getChars(long l, int begin, int end, byte[] value) {103return StringUTF16.getChars(l, begin, end, value);104}105106public static boolean contentEquals(byte[] v1, byte[] v2, int len) {107return StringUTF16.contentEquals(v1, v2, len);108}109110public static boolean contentEquals(byte[] value, CharSequence cs, int len) {111return StringUTF16.contentEquals(value, cs, len);112}113114public static int putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4) {115return StringUTF16.putCharsAt(value, i, c1, c2, c3, c4);116}117118public static int putCharsAt(byte[] value, int i, char c1, char c2, char c3, char c4, char c5) {119return StringUTF16.putCharsAt(value, i, c1, c2, c3, c4, c5);120}121122public static char charAt(byte[] value, int index) {123return StringUTF16.charAt(value, index);124}125126public static void reverse(byte[] value, int count) {127StringUTF16.reverse(value, count);128}129130public static void inflate(byte[] src, int srcOff, byte[] dst, int dstOff, int len) {131StringUTF16.inflate(src, srcOff, dst, dstOff, len);132}133134public static int indexOf(byte[] src, int srcCount,135byte[] tgt, int tgtCount, int fromIndex) {136return StringUTF16.indexOf(src, srcCount, tgt, tgtCount, fromIndex);137}138139public static int indexOfLatin1(byte[] src, int srcCount,140byte[] tgt, int tgtCount, int fromIndex) {141return StringUTF16.indexOfLatin1(src, srcCount, tgt, tgtCount, fromIndex);142}143public static int lastIndexOf(byte[] src, byte[] tgt, int tgtCount, int fromIndex) {144int srcCount = StringUTF16.length(src); // ignored145return StringUTF16.lastIndexOf(src, srcCount, tgt, tgtCount, fromIndex);146}147148public static int lastIndexOfLatin1(byte[] src, byte[] tgt, int tgtCount, int fromIndex) {149int srcCount = StringUTF16.length(src); // ignored150return StringUTF16.lastIndexOfLatin1(src, srcCount, tgt, tgtCount, fromIndex);151}152153}154155156