Skip to content

Commit 51e1c20

Browse files
committed
[GR-42730] Fix warnings on JDK 20
1 parent e3edae7 commit 51e1c20

File tree

23 files changed

+63
-54
lines changed

23 files changed

+63
-54
lines changed

graalpython/com.oracle.graal.python.processor/src/com/oracle/graal/python/processor/ProcessingError.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -44,7 +44,7 @@
4444

4545
final class ProcessingError extends Exception {
4646
private static final long serialVersionUID = -7741682404828028813L;
47-
private final Element element;
47+
private final transient Element element;
4848

4949
ProcessingError(Element element, String fmt, Object... args) {
5050
super(String.format(fmt, args));

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/LocaleModuleBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -88,6 +88,7 @@ public class LocaleModuleBuiltins extends PythonBuiltins {
8888
static final int CHAR_MAX = 127;
8989

9090
@TruffleBoundary
91+
@SuppressWarnings("deprecation") // remove once we move to Java 21
9192
public static Locale fromPosix(TruffleString tposixLocaleId) {
9293
// format: [language[_territory][.variant][@modifier]]
9394
// 2 lower _ 2 UPPER .

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MarshalModuleBuiltins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2017, 2023, Oracle and/or its affiliates.
33
* Copyright (c) 2013, Regents of the University of California
44
*
55
* All rights reserved.
@@ -312,8 +312,8 @@ static final class MarshalError extends RuntimeException {
312312
static final long serialVersionUID = 5323687983726237118L;
313313

314314
final PythonBuiltinClassType type;
315-
final TruffleString message;
316-
final Object[] arguments;
315+
final transient TruffleString message;
316+
final transient Object[] arguments;
317317

318318
MarshalError(PythonBuiltinClassType type, TruffleString message, Object... arguments) {
319319
super(null, null);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MultiprocessingModuleBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -60,6 +60,7 @@
6060
import com.oracle.graal.python.builtins.objects.ints.PInt;
6161
import com.oracle.graal.python.builtins.objects.list.PList;
6262
import com.oracle.graal.python.builtins.objects.thread.PSemLock;
63+
import com.oracle.graal.python.builtins.objects.thread.PThread;
6364
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
6465
import com.oracle.graal.python.lib.PyObjectGetItem;
6566
import com.oracle.graal.python.lib.PyObjectSizeNode;
@@ -201,7 +202,7 @@ abstract static class GetTidNode extends PythonBuiltinNode {
201202
@Specialization
202203
@TruffleBoundary
203204
long getTid() {
204-
return convertTid(getContext().getMainThread().getId());
205+
return convertTid(PThread.getThreadId(getContext().getMainThread()));
205206
}
206207
}
207208

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ResourceModuleBuiltins.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -53,6 +53,7 @@
5353
import com.oracle.graal.python.builtins.Python3Core;
5454
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5555
import com.oracle.graal.python.builtins.PythonBuiltins;
56+
import com.oracle.graal.python.builtins.objects.thread.PThread;
5657
import com.oracle.graal.python.builtins.objects.tuple.PTuple;
5758
import com.oracle.graal.python.builtins.objects.tuple.StructSequence;
5859
import com.oracle.graal.python.nodes.ErrorMessages;
@@ -122,7 +123,7 @@ abstract static class GetRuUsageNode extends PythonBuiltinNode {
122123
@Specialization(guards = {"who == RUSAGE_THREAD"})
123124
@TruffleBoundary
124125
PTuple getruusageThread(@SuppressWarnings("unused") int who) {
125-
long id = Thread.currentThread().getId();
126+
long id = PThread.getThreadId(Thread.currentThread());
126127
Runtime runtime = Runtime.getRuntime();
127128

128129
double ru_utime = 0; // time in user mode (float)

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SysModuleBuiltins.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178
import com.oracle.graal.python.builtins.objects.str.PString;
179179
import com.oracle.graal.python.builtins.objects.str.StringNodes;
180180
import com.oracle.graal.python.builtins.objects.str.StringUtils;
181+
import com.oracle.graal.python.builtins.objects.thread.PThread;
181182
import com.oracle.graal.python.builtins.objects.traceback.GetTracebackNode;
182183
import com.oracle.graal.python.builtins.objects.traceback.LazyTraceback;
183184
import com.oracle.graal.python.builtins.objects.traceback.PTraceback;
@@ -853,7 +854,7 @@ Object currentFrames(VirtualFrame frame,
853854
}
854855
PFrame currentFrame = readCallerFrameNode.executeWith(frame, 0);
855856
PDict result = factory().createDict();
856-
result.setDictStorage(setHashingStorageItem.execute(frame, result.getDictStorage(), Thread.currentThread().getId(), currentFrame));
857+
result.setDictStorage(setHashingStorageItem.execute(frame, result.getDictStorage(), PThread.getThreadId(Thread.currentThread()), currentFrame));
857858
return result;
858859
}
859860
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/ThreadModuleBuiltins.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public abstract static class GetCurrentThreadIdNode extends PythonBuiltinNode {
149149
@Specialization
150150
@TruffleBoundary
151151
public static long getId() {
152-
return Thread.currentThread().getId();
152+
return PThread.getThreadId(Thread.currentThread());
153153
}
154154
}
155155

@@ -159,7 +159,7 @@ public abstract static class GetNativeIdNode extends PythonBuiltinNode {
159159
@Specialization
160160
@TruffleBoundary
161161
public static long getId() {
162-
return Thread.currentThread().getId();
162+
return PThread.getThreadId(Thread.currentThread());
163163
}
164164
}
165165

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/common/LoadCExtException.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
public abstract class LoadCExtException extends Exception {
5151
private static final long serialVersionUID = 3517291912314595890L;
5252
protected final PException cause;
53-
protected final Object name;
54-
protected final TruffleString formatString;
55-
protected final Object[] formatArgs;
53+
protected final transient Object name;
54+
protected final transient TruffleString formatString;
55+
protected final transient Object[] formatArgs;
5656

5757
protected LoadCExtException(PException cause, TruffleString name, TruffleString formatString, Object[] formatArgs) {
5858
/*
@@ -94,7 +94,7 @@ public PException reraise(PConstructAndRaiseNode raiseNode, VirtualFrame frame)
9494

9595
public static final class ImportException extends LoadCExtException {
9696
private static final long serialVersionUID = 7862376523476548L;
97-
private final Object path;
97+
private final transient Object path;
9898

9999
public ImportException(PException cause, TruffleString name, TruffleString path, TruffleString formatString, Object... formatArgs) {
100100
super(cause, name, formatString, formatArgs);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/PRLock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -56,7 +56,7 @@ private static class InternalReentrantLock extends ReentrantLock {
5656
long getOwnerId() {
5757
Thread owner = getOwner();
5858
if (owner != null) {
59-
return owner.getId();
59+
return PThread.getThreadId(owner);
6060
}
6161
return 0;
6262
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/thread/PSemLock.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* The Universal Permissive License (UPL), Version 1.0
@@ -72,7 +72,7 @@ public PSemLock(Object cls, Shape instanceShape, TruffleString name, int kind, S
7272
protected boolean acquireNonBlocking() {
7373
boolean ret = semaphore.tryAcquire();
7474
if (ret) {
75-
lastThreadID = Thread.currentThread().getId();
75+
lastThreadID = PThread.getThreadId(Thread.currentThread());
7676
count++;
7777
}
7878
return ret;
@@ -87,7 +87,7 @@ protected boolean acquireBlocking(Node node) {
8787
b[0] = true;
8888
}, semaphore);
8989
if (b[0]) {
90-
lastThreadID = Thread.currentThread().getId();
90+
lastThreadID = PThread.getThreadId(Thread.currentThread());
9191
count++;
9292
}
9393
return b[0];
@@ -99,7 +99,7 @@ protected boolean acquireTimeout(Node node, long timeout) {
9999
boolean[] b = new boolean[1];
100100
TruffleSafepoint.setBlockedThreadInterruptible(node, (s) -> b[0] = s.tryAcquire(timeout, TimeUnit.MILLISECONDS), semaphore);
101101
if (b[0]) {
102-
lastThreadID = Thread.currentThread().getId();
102+
lastThreadID = PThread.getThreadId(Thread.currentThread());
103103
count++;
104104
}
105105
return b[0];
@@ -129,7 +129,7 @@ public int getCount() {
129129

130130
public void increaseCount() {
131131
count++;
132-
lastThreadID = Thread.currentThread().getId();
132+
lastThreadID = PThread.getThreadId(Thread.currentThread());
133133
}
134134

135135
public void decreaseCount() {
@@ -138,7 +138,7 @@ public void decreaseCount() {
138138

139139
@TruffleBoundary
140140
public boolean isMine() {
141-
return count > 0 && lastThreadID == Thread.currentThread().getId();
141+
return count > 0 && lastThreadID == PThread.getThreadId(Thread.currentThread());
142142
}
143143

144144
public boolean isZero() {

0 commit comments

Comments
 (0)