Skip to content

Commit 46efe3a

Browse files
committed
Merge master HEAD into openj9-staging
Signed-off-by: J9 Build <[email protected]>
2 parents 1bef1f3 + 96c24d5 commit 46efe3a

File tree

115 files changed

+2358
-1284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2358
-1284
lines changed

make/modules/java.desktop/lib/ClientLibraries.gmk

-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ ifeq ($(USE_EXTERNAL_LCMS), true)
7070
# If we're using an external library, we can't include our own SRC path
7171
# as includes, instead the system headers should be used.
7272
LIBLCMS_HEADERS_FROM_SRC := false
73-
# FIXME: Keep old behavior and reset LCMS_CFLAGS. This is likely a bug.
74-
LCMS_CFLAGS :=
7573
endif
7674

7775
ifeq ($(TOOLCHAIN_TYPE)+$(TOOLCHAIN_VERSION), clang+10.1)

src/java.desktop/share/classes/javax/swing/JTable.java

+41-29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2146,42 +2146,54 @@ public boolean getCellSelectionEnabled() {
21462146
return getRowSelectionAllowed() && getColumnSelectionAllowed();
21472147
}
21482148

2149-
/**
2150-
* Selects all rows, columns, and cells in the table.
2151-
*/
2152-
public void selectAll() {
2153-
// If I'm currently editing, then I should stop editing
2154-
if (isEditing()) {
2155-
removeEditor();
2156-
}
2157-
if (getRowCount() > 0 && getColumnCount() > 0) {
2158-
int oldLead;
2159-
int oldAnchor;
2160-
ListSelectionModel selModel;
2149+
private void selectRows(int rowCount) {
2150+
ListSelectionModel selModel = selectionModel;
2151+
selModel.setValueIsAdjusting(true);
2152+
int oldLead = getAdjustedIndex(selModel.getLeadSelectionIndex(), true);
2153+
int oldAnchor = getAdjustedIndex(selModel.getAnchorSelectionIndex(), true);
21612154

2162-
selModel = selectionModel;
2163-
selModel.setValueIsAdjusting(true);
2164-
oldLead = getAdjustedIndex(selModel.getLeadSelectionIndex(), true);
2165-
oldAnchor = getAdjustedIndex(selModel.getAnchorSelectionIndex(), true);
2155+
setRowSelectionInterval(0, rowCount - 1);
21662156

2167-
setRowSelectionInterval(0, getRowCount()-1);
2157+
// this is done to restore the anchor and lead
2158+
SwingUtilities2.setLeadAnchorWithoutSelection(selModel, oldLead, oldAnchor);
2159+
2160+
selModel.setValueIsAdjusting(false);
2161+
}
21682162

2169-
// this is done to restore the anchor and lead
2170-
SwingUtilities2.setLeadAnchorWithoutSelection(selModel, oldLead, oldAnchor);
2163+
private void selectColumns(int columnCount) {
2164+
ListSelectionModel selModel = columnModel.getSelectionModel();
2165+
selModel.setValueIsAdjusting(true);
2166+
int oldLead = getAdjustedIndex(selModel.getLeadSelectionIndex(), false);
2167+
int oldAnchor = getAdjustedIndex(selModel.getAnchorSelectionIndex(), false);
21712168

2172-
selModel.setValueIsAdjusting(false);
2169+
setColumnSelectionInterval(0, columnCount - 1);
21732170

2174-
selModel = columnModel.getSelectionModel();
2175-
selModel.setValueIsAdjusting(true);
2176-
oldLead = getAdjustedIndex(selModel.getLeadSelectionIndex(), false);
2177-
oldAnchor = getAdjustedIndex(selModel.getAnchorSelectionIndex(), false);
2171+
// this is done to restore the anchor and lead
2172+
SwingUtilities2.setLeadAnchorWithoutSelection(selModel, oldLead, oldAnchor);
21782173

2179-
setColumnSelectionInterval(0, getColumnCount()-1);
2174+
selModel.setValueIsAdjusting(false);
2175+
}
21802176

2181-
// this is done to restore the anchor and lead
2182-
SwingUtilities2.setLeadAnchorWithoutSelection(selModel, oldLead, oldAnchor);
2177+
/**
2178+
* Selects all rows, columns, and cells in the table.
2179+
*/
2180+
public void selectAll() {
2181+
int rowCount = getRowCount();
2182+
int columnCount = getColumnCount();
21832183

2184-
selModel.setValueIsAdjusting(false);
2184+
// If I'm currently editing, then I should stop editing
2185+
if (isEditing()) {
2186+
removeEditor();
2187+
}
2188+
if (rowCount > 0 && columnCount > 0) {
2189+
selectRows(rowCount);
2190+
selectColumns(columnCount);
2191+
} else if (rowCount > 0 && columnCount == 0
2192+
&& getRowSelectionAllowed()) {
2193+
selectRows(rowCount);
2194+
} else if (columnCount > 0 && rowCount == 0
2195+
&& getColumnSelectionAllowed()) {
2196+
selectColumns(columnCount);
21852197
}
21862198
}
21872199

src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2005, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1070,6 +1070,11 @@ public String getText() {
10701070
return "";
10711071
}
10721072

1073+
@Override
1074+
public Comment stripIndent() {
1075+
return this;
1076+
}
1077+
10731078
@Override
10741079
public JCDiagnostic.DiagnosticPosition getPos() {
10751080
return null;

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/DocCommentParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2012, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -158,7 +158,7 @@ public DocCommentParser(ParserFactory fac, DiagnosticSource diagSource,
158158
this.fac = fac;
159159
this.diags = fac.log.diags;
160160
this.diagSource = diagSource;
161-
this.comment = comment;
161+
this.comment = comment.stripIndent();
162162
names = fac.names;
163163
this.isHtmlFile = isHtmlFile;
164164
textKind = isHtmlFile ? DocTree.Kind.TEXT : getTextKind(comment);

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java

+15
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,21 @@ public String getText() {
12651265
return null;
12661266
}
12671267

1268+
/**
1269+
* Return a version of this comment with incidental whitespace removed,
1270+
* or this comment if the operation is not supported.
1271+
*
1272+
* @return comment with removed whitespace or this comment
1273+
*/
1274+
public Comment stripIndent() {
1275+
return this;
1276+
}
1277+
1278+
/**
1279+
* Return the diagnostic position of this comment.
1280+
*
1281+
* @return diagnostic position
1282+
*/
12681283
public DiagnosticPosition getPos() {
12691284
return pos;
12701285
}

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java

+158-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2004, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -27,11 +27,11 @@
2727

2828
import com.sun.tools.javac.parser.Tokens.Comment;
2929
import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle;
30-
import com.sun.tools.javac.util.*;
30+
import com.sun.tools.javac.util.JCDiagnostic;
31+
import com.sun.tools.javac.util.Position;
3132

3233
import java.nio.CharBuffer;
3334
import java.util.Arrays;
34-
import java.util.regex.Pattern;
3535

3636
/**
3737
* An extension to the base lexical analyzer (JavaTokenizer) that
@@ -170,6 +170,11 @@ protected void scanDocComment() {
170170
offsetMap.trim();
171171
}
172172
}
173+
174+
@Override
175+
public Comment stripIndent() {
176+
return StrippedComment.of(this);
177+
}
173178
}
174179

175180
/**
@@ -354,4 +359,154 @@ int getSourcePos(int pos) {
354359
return map[startScaled + POS_OFFSET] + (pos - map[startScaled + SB_OFFSET]);
355360
}
356361
}
362+
363+
/**
364+
* A Comment derived from a JavadocComment with leading whitespace removed from all lines.
365+
* A new OffsetMap is used in combination with the OffsetMap of the original comment to
366+
* translate comment locations to positions in the source file.
367+
*
368+
* Note: This class assumes new lines are encoded as {@code '\n'}, which is the case
369+
* for comments created by {@code JavadocTokenizer}.
370+
*/
371+
static class StrippedComment implements Comment {
372+
String text;
373+
final OffsetMap strippedMap;
374+
final OffsetMap sourceMap;
375+
// Copy these fields to not hold a reference to the original comment with its text
376+
final JCDiagnostic.DiagnosticPosition diagPos;
377+
final CommentStyle style;
378+
final boolean deprecated;
379+
380+
/**
381+
* Returns a stripped version of the comment, or the comment itself if there is no
382+
* whitespace that can be stripped.
383+
*
384+
* @param comment the original comment
385+
* @return stripped or original comment
386+
*/
387+
static Comment of(JavadocComment comment) {
388+
if (comment.getStyle() != CommentStyle.JAVADOC_BLOCK) {
389+
return comment;
390+
}
391+
int indent = getIndent(comment);
392+
return indent > 0 ? new StrippedComment(comment, indent) : comment;
393+
}
394+
395+
private StrippedComment(JavadocComment comment, int indent) {
396+
this.diagPos = comment.getPos();
397+
this.style = comment.getStyle();
398+
this.deprecated = comment.isDeprecated();
399+
this.strippedMap = new OffsetMap();
400+
this.sourceMap = comment.offsetMap;
401+
stripComment(comment, indent);
402+
}
403+
404+
/**
405+
* Determines the number of leading whitespace characters that can be removed from
406+
* all non-blank lines of the original comment.
407+
*
408+
* @param comment the original comment
409+
* @return number of leading whitespace characters that can be reomved
410+
*/
411+
static int getIndent(Comment comment) {
412+
String txt = comment.getText();
413+
int len = txt.length();
414+
int indent = Integer.MAX_VALUE;
415+
416+
for (int i = 0; i < len; ) {
417+
int next;
418+
boolean inIndent = true;
419+
for (next = i; next < len && txt.charAt(next) != '\n'; next++) {
420+
if (inIndent && !Character.isWhitespace(txt.charAt(next))) {
421+
indent = Math.min(indent, next - i);
422+
inIndent = false;
423+
}
424+
}
425+
i = next + 1;
426+
}
427+
428+
return indent == Integer.MAX_VALUE ? 0 : indent;
429+
}
430+
431+
/**
432+
* Strips {@code indent} whitespace characters from every line of the original comment
433+
* and initializes an OffsetMap to translate positions to the original comment's OffsetMap.
434+
* This method does not distinguish between blank and non-blank lines except for the fact
435+
* that blank lines are not required to contain the number of leading whitespace indicated
436+
* by {@indent}.
437+
*
438+
* @param comment the original comment
439+
* @param indent number of whitespace characters to remove from each non-blank line
440+
*/
441+
private void stripComment(JavadocComment comment, int indent) {
442+
String txt = comment.getText();
443+
int len = txt.length();
444+
StringBuilder sb = new StringBuilder(len);
445+
446+
for (int i = 0; i < len; ) {
447+
int startOfLine = i;
448+
// Advance till start of stripped line, or \n if line is blank
449+
while (startOfLine < len
450+
&& startOfLine < i + indent
451+
&& txt.charAt(startOfLine) != '\n') {
452+
assert(Character.isWhitespace(txt.charAt(startOfLine)));
453+
startOfLine++;
454+
}
455+
if (startOfLine == len) {
456+
break;
457+
}
458+
459+
// Copy stripped line (terminated by \n or end of input)
460+
i = startOfLine + 1;
461+
while (i < len && txt.charAt(i - 1) != '\n') {
462+
i++;
463+
}
464+
// Add new offset if necessary
465+
strippedMap.add(sb.length(), startOfLine);
466+
sb.append(txt, startOfLine, i);
467+
}
468+
469+
text = sb.toString();
470+
strippedMap.trim();
471+
}
472+
473+
@Override
474+
public String getText() {
475+
return text;
476+
}
477+
478+
@Override
479+
public Comment stripIndent() {
480+
return this;
481+
}
482+
483+
@Override
484+
public int getSourcePos(int pos) {
485+
if (pos == Position.NOPOS) {
486+
return Position.NOPOS;
487+
}
488+
489+
if (pos < 0 || pos > text.length()) {
490+
throw new StringIndexOutOfBoundsException(String.valueOf(pos));
491+
}
492+
493+
return sourceMap.getSourcePos(strippedMap.getSourcePos(pos));
494+
}
495+
496+
@Override
497+
public JCDiagnostic.DiagnosticPosition getPos() {
498+
return diagPos;
499+
}
500+
501+
@Override
502+
public CommentStyle getStyle() {
503+
return style;
504+
}
505+
506+
@Override
507+
public boolean isDeprecated() {
508+
return deprecated;
509+
}
510+
}
511+
357512
}

src/jdk.compiler/share/classes/com/sun/tools/javac/parser/Tokens.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -281,6 +281,7 @@ enum CommentStyle {
281281
}
282282

283283
String getText();
284+
Comment stripIndent();
284285
JCDiagnostic.DiagnosticPosition getPos();
285286
int getSourcePos(int index);
286287
CommentStyle getStyle();

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocPretty.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public Void visitLiteral(LiteralTree node, Void p) {
345345
print('{');
346346
printTagName(node);
347347
String body = node.getBody().getBody();
348-
if (!body.isEmpty() && !Character.isWhitespace(body.charAt(0))) {
348+
if (!body.isEmpty() && body.charAt(0) != '\n') {
349349
print(' ');
350350
}
351351
print(node.getBody());

src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DocTreeMaker.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -236,6 +236,9 @@ public String getText() {
236236
throw new UnsupportedOperationException(getClass() + ".getText");
237237
}
238238

239+
@Override
240+
public Comment stripIndent() { return this; }
241+
239242
@Override
240243
public CommentStyle getStyle() {
241244
throw new UnsupportedOperationException(getClass() + ".getStyle");

0 commit comments

Comments
 (0)