src/hotspot/share/utilities/utf8.cpp
changeset 51823 2a51125b2794
parent 47216 71c04702a3d5
child 53731 ee45b48c9e4a
--- a/src/hotspot/share/utilities/utf8.cpp	Thu Sep 20 18:39:53 2018 +0200
+++ b/src/hotspot/share/utilities/utf8.cpp	Tue Sep 18 21:47:14 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -401,7 +401,7 @@
   return (c <= 0x00FF);
 }
 
-bool UNICODE::is_latin1(jchar* base, int length) {
+bool UNICODE::is_latin1(const jchar* base, int length) {
   for (int index = 0; index < length; index++) {
     if (base[index] > 0x00FF) {
       return false;
@@ -434,7 +434,7 @@
 }
 
 template<typename T>
-int UNICODE::utf8_length(T* base, int length) {
+int UNICODE::utf8_length(const T* base, int length) {
   int result = 0;
   for (int index = 0; index < length; index++) {
     T c = base[index];
@@ -444,7 +444,7 @@
 }
 
 template<typename T>
-char* UNICODE::as_utf8(T* base, int& length) {
+char* UNICODE::as_utf8(const T* base, int& length) {
   int utf8_len = utf8_length(base, length);
   u_char* buf = NEW_RESOURCE_ARRAY(u_char, utf8_len + 1);
   char* result = as_utf8(base, length, (char*) buf, utf8_len + 1);
@@ -454,7 +454,7 @@
   return (char*) result;
 }
 
-char* UNICODE::as_utf8(jchar* base, int length, char* buf, int buflen) {
+char* UNICODE::as_utf8(const jchar* base, int length, char* buf, int buflen) {
   u_char* p = (u_char*)buf;
   for (int index = 0; index < length; index++) {
     jchar c = base[index];
@@ -466,7 +466,7 @@
   return buf;
 }
 
-char* UNICODE::as_utf8(jbyte* base, int length, char* buf, int buflen) {
+char* UNICODE::as_utf8(const jbyte* base, int length, char* buf, int buflen) {
   u_char* p = (u_char*)buf;
   u_char* end = (u_char*)buf + buflen;
   for (int index = 0; index < length; index++) {
@@ -496,7 +496,7 @@
 
 // returns the quoted ascii length of a unicode string
 template<typename T>
-int UNICODE::quoted_ascii_length(T* base, int length) {
+int UNICODE::quoted_ascii_length(const T* base, int length) {
   int result = 0;
   for (int i = 0; i < length; i++) {
     T c = base[i];
@@ -529,11 +529,11 @@
 }
 
 // Explicit instantiation for all supported types.
-template int UNICODE::utf8_length(jbyte* base, int length);
-template int UNICODE::utf8_length(jchar* base, int length);
-template char* UNICODE::as_utf8(jbyte* base, int& length);
-template char* UNICODE::as_utf8(jchar* base, int& length);
-template int UNICODE::quoted_ascii_length<jbyte>(jbyte* base, int length);
-template int UNICODE::quoted_ascii_length<jchar>(jchar* base, int length);
+template int UNICODE::utf8_length(const jbyte* base, int length);
+template int UNICODE::utf8_length(const jchar* base, int length);
+template char* UNICODE::as_utf8(const jbyte* base, int& length);
+template char* UNICODE::as_utf8(const jchar* base, int& length);
+template int UNICODE::quoted_ascii_length<jbyte>(const jbyte* base, int length);
+template int UNICODE::quoted_ascii_length<jchar>(const jchar* base, int length);
 template void UNICODE::as_quoted_ascii<jbyte>(const jbyte* base, int length, char* buf, int buflen);
 template void UNICODE::as_quoted_ascii<jchar>(const jchar* base, int length, char* buf, int buflen);