forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that parameter names read from bytecode aren't obliterated by …
…generic signatures. c78d771 added code to parse the `MethodParameters` attribute from Java classfiles. However, if `javac` emits a `Signature` attribute after the `MethodParameters` attribute, the method info (previously parsed from the descriptor) is overwritten with the generic info, which doesn't keep the parameter symbols from the description-based info. Therefore, collect names in a buffer until all attributes are parsed, then attach them to the parameter symbols in the final info. Also, use the Java reflection `getParameters` method to populate these parameter symbols in runtime reflection. Fixes scala/bug#t10699.
- Loading branch information
Showing
11 changed files
with
104 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* javac: -parameters | ||
*/ | ||
public class J_1<T> { | ||
public J_1(int i, int j) {} | ||
public <J extends T> void inst(int i, J j) {} | ||
public static <J> void statik(int i, J j) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
object Test extends App { | ||
import reflect.runtime.universe._ | ||
|
||
val j_1 = symbolOf[J_1[_]] | ||
val constr = j_1.info.decl(termNames.CONSTRUCTOR) | ||
val inst = j_1.info.decl(TermName("inst")) | ||
val statik = j_1.companion.info.decl(TermName("statik")) | ||
|
||
def check(info: Type) { | ||
assert(info.paramLists.head.map(_.name) == List(TermName("i"), TermName("j")), info) | ||
} | ||
|
||
check(constr.info) | ||
check(inst.info) | ||
check(statik.info) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* javac: -parameters | ||
*/ | ||
public class A_1 { | ||
public <T> T identity_inst(T t, T other) { return t; } | ||
public static <T> T identity_static(T t, T other) { return t; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
object Test extends App { | ||
val a_1 = new A_1 | ||
val t = "t" | ||
val other = "other" | ||
assert(a_1.identity_inst(other = other, t = t) == t) | ||
assert(A_1.identity_static(other = other, t = t) == t) | ||
} |
File renamed without changes.