Skip to content

Commit 344e3dc

Browse files
cushonError Prone Team
authored andcommitted
Remove an obsolete use of reflection
This worked around a change in JDK 16 (https://bugs.openjdk.org/browse/JDK-8254073) PiperOrigin-RevId: 821956420
1 parent 5f46e62 commit 344e3dc

1 file changed

Lines changed: 1 addition & 19 deletions

File tree

check_api/src/main/java/com/google/errorprone/util/ErrorProneTokens.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public Map<Comment, ErrorProneComment> comments() {
113113

114114
@Override
115115
protected Comment processComment(int pos, int endPos, CommentStyle style) {
116-
char[] buf = getRawCharactersReflectively(pos, endPos);
116+
char[] buf = getRawCharacters(pos, endPos);
117117
Comment comment = super.processComment(pos, endPos, style);
118118
AccessibleReader reader = new AccessibleReader(fac, buf, buf.length);
119119
ErrorProneComment errorProneComment =
@@ -126,24 +126,6 @@ protected Comment processComment(int pos, int endPos, CommentStyle style) {
126126
comments.put(comment, errorProneComment);
127127
return comment;
128128
}
129-
130-
private char[] getRawCharactersReflectively(int beginIndex, int endIndex) {
131-
Object instance;
132-
try {
133-
instance = JavaTokenizer.class.getDeclaredField("reader").get(this);
134-
} catch (ReflectiveOperationException e) {
135-
instance = this;
136-
}
137-
try {
138-
return (char[])
139-
instance
140-
.getClass()
141-
.getMethod("getRawCharacters", int.class, int.class)
142-
.invoke(instance, beginIndex, endIndex);
143-
} catch (ReflectiveOperationException e) {
144-
throw new LinkageError(e.getMessage(), e);
145-
}
146-
}
147129
}
148130

149131
// Scanner(ScannerFactory, JavaTokenizer) is package-private

0 commit comments

Comments
 (0)