Skip to content

Commit 7759531

Browse files
committed
8176188: jdk/internal/misc/JavaLangAccess/NewUnsafeString.java failing since 9-b93
Reviewed-by: psandoz, sherman
1 parent 6351f58 commit 7759531

9 files changed

Lines changed: 5 additions & 138 deletions

File tree

src/java.base/share/classes/java/lang/String.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -645,19 +645,6 @@ public String(StringBuilder builder) {
645645
this(builder, null);
646646
}
647647

648-
/*
649-
* Package private constructor which shares value array for speed.
650-
* this constructor is always expected to be called with share==true.
651-
* a separate constructor is needed because we already have a public
652-
* String(char[]) constructor that makes a copy of the given char[].
653-
*/
654-
// TBD: this is kept for package internal use (Thread/System),
655-
// should be removed if they all have a byte[] version
656-
String(char[] val, boolean share) {
657-
// assert share : "unshared not supported";
658-
this(val, 0, val.length, null);
659-
}
660-
661648
/**
662649
* Returns the length of this string.
663650
* The length is equal to the number of <a href="Character.html#unicode">Unicode

src/java.base/share/classes/java/lang/System.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2109,9 +2109,6 @@ public void blockedOn(Thread t, Interruptible b) {
21092109
public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
21102110
Shutdown.add(slot, registerShutdownInProgress, hook);
21112111
}
2112-
public String newStringUnsafe(char[] chars) {
2113-
return new String(chars, true);
2114-
}
21152112
public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
21162113
return new Thread(target, acc);
21172114
}

src/java.base/share/classes/java/util/StringJoiner.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
*/
2525
package java.util;
2626

27-
import jdk.internal.misc.JavaLangAccess;
28-
import jdk.internal.misc.SharedSecrets;
29-
3027
/**
3128
* {@code StringJoiner} is used to construct a sequence of characters separated
3229
* by a delimiter and optionally starting with a supplied prefix
@@ -86,8 +83,6 @@ public final class StringJoiner {
8683
*/
8784
private String emptyValue;
8885

89-
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
90-
9186
/**
9287
* Constructs a {@code StringJoiner} with no characters in it, with no
9388
* {@code prefix} or {@code suffix}, and a copy of the supplied
@@ -189,7 +184,7 @@ public String toString() {
189184
}
190185
}
191186
k += getChars(suffix, chars, k);
192-
return jla.newStringUnsafe(chars);
187+
return new String(chars);
193188
}
194189

195190
/**
@@ -252,7 +247,7 @@ private void compactElts() {
252247
elts[i] = null;
253248
} while (++i < size);
254249
size = 1;
255-
elts[0] = jla.newStringUnsafe(chars);
250+
elts[0] = new String(chars);
256251
}
257252
}
258253

src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,6 @@ public interface JavaLangAccess {
123123
*/
124124
void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook);
125125

126-
/**
127-
* Returns a new string backed by the provided character array. The
128-
* character array is not copied and must never be modified after the
129-
* String is created, in order to fulfill String's contract.
130-
*
131-
* @param chars the character array to back the string
132-
* @return a newly created string whose content is the character array
133-
*/
134-
String newStringUnsafe(char[] chars);
135-
136126
/**
137127
* Returns a new Thread with the given Runnable and an
138128
* inherited AccessControlContext.

src/java.sql/share/classes/java/sql/Date.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
import java.time.Instant;
2929
import java.time.LocalDate;
30-
import jdk.internal.misc.SharedSecrets;
31-
import jdk.internal.misc.JavaLangAccess;
3230

3331
/**
3432
* <P>A thin wrapper around a millisecond value that allows
@@ -46,8 +44,6 @@
4644
*/
4745
public class Date extends java.util.Date {
4846

49-
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
50-
5147
/**
5248
* Constructs a <code>Date</code> object initialized with the given
5349
* year, month, and day.
@@ -168,7 +164,7 @@ public String toString () {
168164
buf[7] = '-';
169165
Date.formatDecimalInt(day, buf, 8, 2);
170166

171-
return jla.newStringUnsafe(buf);
167+
return new String(buf);
172168
}
173169

174170
/**

src/java.sql/share/classes/java/sql/Time.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
import java.time.Instant;
2929
import java.time.LocalTime;
30-
import jdk.internal.misc.SharedSecrets;
31-
import jdk.internal.misc.JavaLangAccess;
3230

3331
/**
3432
* <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
@@ -43,8 +41,6 @@
4341
*/
4442
public class Time extends java.util.Date {
4543

46-
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
47-
4844
/**
4945
* Constructs a <code>Time</code> object initialized with the
5046
* given values for the hour, minute, and second.
@@ -134,7 +130,7 @@ public String toString () {
134130
buf[5] = ':';
135131
Date.formatDecimalInt(second, buf, 6, 2);
136132

137-
return jla.newStringUnsafe(buf);
133+
return new String(buf);
138134
}
139135

140136
// Override all the date operations inherited from java.util.Date;

src/java.sql/share/classes/java/sql/Timestamp.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727

2828
import java.time.Instant;
2929
import java.time.LocalDateTime;
30-
import jdk.internal.misc.SharedSecrets;
31-
import jdk.internal.misc.JavaLangAccess;
3230

3331
/**
3432
* <P>A thin wrapper around {@code java.util.Date} that allows
@@ -74,8 +72,6 @@
7472
*/
7573
public class Timestamp extends java.util.Date {
7674

77-
private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
78-
7975
/**
8076
* Constructs a {@code Timestamp} object initialized
8177
* with the given values.
@@ -313,7 +309,7 @@ public String toString() {
313309
buf[yearSize + 15] = '.';
314310
Date.formatDecimalInt(tmpNanos, buf, yearSize + 16, 9 - trailingZeros);
315311

316-
return jla.newStringUnsafe(buf);
312+
return new String(buf);
317313
}
318314

319315
/**

test/jdk/ProblemList.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 gen
124124

125125
java/lang/StringCoding/CheckEncodings.sh 7008363 generic-all
126126

127-
jdk/internal/misc/JavaLangAccess/NewUnsafeString.java 8176188 generic-all
128-
129127
java/lang/String/nativeEncoding/StringPlatformChars.java 8182569 windows-all,solaris-all
130128

131129
############################################################################

test/jdk/jdk/internal/misc/JavaLangAccess/NewUnsafeString.java

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)