77 f(reflect_UnsafeStaticFieldAccessorImpl) \
78 f(java_lang_reflect_Parameter) \
79 f(java_lang_Module) \
80 f(java_lang_StackTraceElement) \
81 f(java_lang_StackFrameInfo) \
82 f(java_lang_LiveStackFrameInfo) \
83 f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
84 f(jdk_internal_misc_UnsafeConstants) \
85 //end
86
87 #define BASIC_JAVA_CLASSES_DO(f) \
88 BASIC_JAVA_CLASSES_DO_PART1(f) \
89 BASIC_JAVA_CLASSES_DO_PART2(f)
90
91 // Interface to java.lang.String objects
92
93 class java_lang_String : AllStatic {
94 private:
95 static int value_offset;
96 static int hash_offset;
97 static int coder_offset;
98
99 static bool initialized;
100
101 static Handle basic_create(int length, bool byte_arr, TRAPS);
102
103 static inline void set_coder(oop string, jbyte coder);
104
105 public:
106
107 // Coders
108 enum Coder {
109 CODER_LATIN1 = 0,
110 CODER_UTF16 = 1
111 };
112
113 static void compute_offsets();
114 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
115
116 // Instance creation
117 static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
118 static oop create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
119 static Handle create_from_str(const char* utf8_str, TRAPS);
120 static oop create_oop_from_str(const char* utf8_str, TRAPS);
121 static Handle create_from_symbol(Symbol* symbol, TRAPS);
122 static Handle create_from_platform_dependent_str(const char* str, TRAPS);
123 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
124
125 static void set_compact_strings(bool value);
126
127 static int value_offset_in_bytes() {
128 assert(initialized && (value_offset > 0), "Must be initialized");
129 return value_offset;
130 }
131 static int hash_offset_in_bytes() {
132 assert(initialized && (hash_offset > 0), "Must be initialized");
133 return hash_offset;
134 }
135 static int coder_offset_in_bytes() {
136 assert(initialized && (coder_offset > 0), "Must be initialized");
137 return coder_offset;
138 }
139
140 static inline void set_value_raw(oop string, typeArrayOop buffer);
141 static inline void set_value(oop string, typeArrayOop buffer);
142 static inline void set_hash(oop string, unsigned int hash);
143
144 // Accessors
145 static inline typeArrayOop value(oop java_string);
146 static inline typeArrayOop value_no_keepalive(oop java_string);
147 static inline unsigned int hash(oop java_string);
148 static inline bool is_latin1(oop java_string);
149 static inline int length(oop java_string);
150 static inline int length(oop java_string, typeArrayOop string_value);
151 static int utf8_length(oop java_string);
152 static int utf8_length(oop java_string, typeArrayOop string_value);
153
154 // String converters
155 static char* as_utf8_string(oop java_string);
156 static char* as_utf8_string(oop java_string, char* buf, int buflen);
157 static char* as_utf8_string(oop java_string, int start, int len);
158 static char* as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
159 static char* as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
160 static char* as_platform_dependent_str(Handle java_string, TRAPS);
161 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
162 // produce an ascii string with all other values quoted using \u####
163 static char* as_quoted_ascii(oop java_string);
164
165 // Compute the hash value for a java.lang.String object which would
166 // contain the characters passed in.
167 //
|
77 f(reflect_UnsafeStaticFieldAccessorImpl) \
78 f(java_lang_reflect_Parameter) \
79 f(java_lang_Module) \
80 f(java_lang_StackTraceElement) \
81 f(java_lang_StackFrameInfo) \
82 f(java_lang_LiveStackFrameInfo) \
83 f(java_util_concurrent_locks_AbstractOwnableSynchronizer) \
84 f(jdk_internal_misc_UnsafeConstants) \
85 //end
86
87 #define BASIC_JAVA_CLASSES_DO(f) \
88 BASIC_JAVA_CLASSES_DO_PART1(f) \
89 BASIC_JAVA_CLASSES_DO_PART2(f)
90
91 // Interface to java.lang.String objects
92
93 class java_lang_String : AllStatic {
94 private:
95 static int value_offset;
96 static int hash_offset;
97 static int hashIsZero_offset;
98 static int coder_offset;
99
100 static bool initialized;
101
102 static Handle basic_create(int length, bool byte_arr, TRAPS);
103
104 static inline void set_coder(oop string, jbyte coder);
105
106 public:
107
108 // Coders
109 enum Coder {
110 CODER_LATIN1 = 0,
111 CODER_UTF16 = 1
112 };
113
114 static void compute_offsets();
115 static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
116
117 // Instance creation
118 static Handle create_from_unicode(const jchar* unicode, int len, TRAPS);
119 static oop create_oop_from_unicode(const jchar* unicode, int len, TRAPS);
120 static Handle create_from_str(const char* utf8_str, TRAPS);
121 static oop create_oop_from_str(const char* utf8_str, TRAPS);
122 static Handle create_from_symbol(Symbol* symbol, TRAPS);
123 static Handle create_from_platform_dependent_str(const char* str, TRAPS);
124 static Handle char_converter(Handle java_string, jchar from_char, jchar to_char, TRAPS);
125
126 static void set_compact_strings(bool value);
127
128 static int value_offset_in_bytes() {
129 assert(initialized && (value_offset > 0), "Must be initialized");
130 return value_offset;
131 }
132 static int hash_offset_in_bytes() {
133 assert(initialized && (hash_offset > 0), "Must be initialized");
134 return hash_offset;
135 }
136 static int hashIsZero_offset_in_bytes() {
137 assert(initialized && (hashIsZero_offset > 0), "Must be initialized");
138 return hashIsZero_offset;
139 }
140 static int coder_offset_in_bytes() {
141 assert(initialized && (coder_offset > 0), "Must be initialized");
142 return coder_offset;
143 }
144
145 static inline void set_value_raw(oop string, typeArrayOop buffer);
146 static inline void set_value(oop string, typeArrayOop buffer);
147
148 // Accessors
149 static inline typeArrayOop value(oop java_string);
150 static inline typeArrayOop value_no_keepalive(oop java_string);
151 static inline bool hash_is_set(oop string);
152 static inline bool is_latin1(oop java_string);
153 static inline int length(oop java_string);
154 static inline int length(oop java_string, typeArrayOop string_value);
155 static int utf8_length(oop java_string);
156 static int utf8_length(oop java_string, typeArrayOop string_value);
157
158 // String converters
159 static char* as_utf8_string(oop java_string);
160 static char* as_utf8_string(oop java_string, char* buf, int buflen);
161 static char* as_utf8_string(oop java_string, int start, int len);
162 static char* as_utf8_string(oop java_string, typeArrayOop value, char* buf, int buflen);
163 static char* as_utf8_string(oop java_string, typeArrayOop value, int start, int len, char* buf, int buflen);
164 static char* as_platform_dependent_str(Handle java_string, TRAPS);
165 static jchar* as_unicode_string(oop java_string, int& length, TRAPS);
166 // produce an ascii string with all other values quoted using \u####
167 static char* as_quoted_ascii(oop java_string);
168
169 // Compute the hash value for a java.lang.String object which would
170 // contain the characters passed in.
171 //
|