Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassfileParser: allow missing param names (for JDK 21) #10397

Merged
merged 1 commit into from May 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -825,7 +825,10 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) {
val paramNameAccess = new Array[Int](paramCount)
var i = 0
while (i < paramCount) {
paramNames(i) = pool.getExternalName(u2)
paramNames(i) = u2() match {
case 0 => null // may occur on JDK 21+, as per scala/bug#12783
case index => pool.getExternalName(index)
}
paramNameAccess(i) = u2
i += 1
}
Expand Down Expand Up @@ -1248,6 +1251,7 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) {
sym setInfo createFromClonedSymbols(alias.initialize.typeParams, alias.tpe)(typeFun)
}
}
// on JDK 21+, `names` may include nulls, as per scala/bug#12783
private class ParamNames(val names: Array[NameOrString], val access: Array[Int]) {
assert(names.length == access.length)
def length = names.length
Expand Down Expand Up @@ -1351,8 +1355,10 @@ abstract class ClassfileParser(reader: ReusableInstance[ReusableDataReader]) {
case (i, param) =>
val isSynthetic = (paramNames.access(i) & ACC_SYNTHETIC) != 0
if (!isSynthetic) {
param.name = paramNames.names(i).name.toTermName.encode
param.resetFlag(SYNTHETIC)
val nameOrString = paramNames.names(i)
if (nameOrString != null)
param.name = nameOrString.name.toTermName.encode
}
}
// there's not anything we can do, but it's slightly worrisome
Expand Down