8305688: jdk build --with-memory-size=1024 broken by JDK-8305100

Reviewed-by: martin
This commit is contained in:
Jim Laskey 2023-04-13 11:42:00 +00:00
parent 646b666a26
commit 2060c8ea14
2 changed files with 27 additions and 12 deletions

View File

@ -96,7 +96,7 @@ public class JavadocTokenizer extends JavaTokenizer {
/**
* StringBuilder used to extract the relevant portion of the Javadoc comment.
*/
private final StringBuilder sb;
private StringBuilder sb;
/**
* Indicates if newline is required.
@ -166,6 +166,8 @@ public class JavadocTokenizer extends JavaTokenizer {
super.scanDocComment();
} finally {
docComment = sb.toString();
sb = null;
offsetMap.trim();
}
}
}
@ -310,6 +312,13 @@ public class JavadocTokenizer extends JavaTokenizer {
}
}
/**
* Reduce map to minimum size.
*/
void trim() {
map = Arrays.copyOf(map, size);
}
/**
* Binary search to find the entry for which the string index is less
* than pos. Since the map is a list of pairs of integers we must make

View File

@ -54,6 +54,11 @@ public class UnicodeReader {
*/
private final int length;
/**
* Virtual position offset in the original buffer.
*/
private final int offset;
/**
* Character buffer index of character currently being observed.
*/
@ -115,7 +120,7 @@ public class UnicodeReader {
* @param length length of meaningful content in buffer.
*/
protected UnicodeReader(Log log, char[] array, int length) {
this(log, array, 0, length);
this(log, array, 0, 0, length);
}
/**
@ -127,9 +132,10 @@ public class UnicodeReader {
* @param endPos end of meaningful content in buffer.
*/
@SuppressWarnings("this-escape")
protected UnicodeReader(Log log, char[] array, int pos, int endPos) {
protected UnicodeReader(Log log, char[] array, int offset, int pos, int endPos) {
this.buffer = array;
this.length = endPos;
this.offset = offset;
this.position = pos;
this.width = 0;
this.character = '\0';
@ -315,22 +321,22 @@ public class UnicodeReader {
}
/**
* Return the current position in the character buffer.
* Return the virtual position in the character buffer.
*
* @return current position in the character buffer.
* @return virtual position in the character buffer.
*/
protected int position() {
return position;
return offset + position;
}
/**
* Reset the reader to the specified position.
* Reset the reader to the specified virtual position.
* Warning: Do not use when previous character was an ASCII or unicode backslash.
* @param pos
*/
protected void reset(int pos) {
position = pos;
position = pos - offset;
width = 0;
wasBackslash = false;
wasUnicodeEscape = false;
@ -474,7 +480,7 @@ public class UnicodeReader {
int endPos = position;
accept('\r');
accept('\n');
return lineReader(pos, endPos);
return new UnicodeReader(log, buffer, offset, pos, endPos);
}
/**
@ -487,7 +493,7 @@ public class UnicodeReader {
* @return a new reader
*/
protected UnicodeReader lineReader(int pos, int endPos) {
return new UnicodeReader(log, buffer, pos, endPos);
return new UnicodeReader(log, buffer, offset, pos - offset, endPos - offset);
}
/**
@ -561,7 +567,7 @@ public class UnicodeReader {
}
// Be prepared to retreat if not a match.
int savedPosition = position;
int savedPosition = position();
nextCodePoint();
@ -695,7 +701,7 @@ public class UnicodeReader {
* @param endPos end of meaningful content in buffer.
*/
protected PositionTrackingReader(UnicodeReader reader, int pos, int endPos) {
super(reader.log, reader.buffer, pos, endPos);
super(reader.log, reader.getRawCharacters(pos, endPos), reader.offset + pos, 0, endPos - pos);
this.column = 0;
}