Skip to content

Commit

Permalink
Issue #660: fixed metadata signature for methods with parameterized r…
Browse files Browse the repository at this point in the history
…eturn types.

	Change on 2015/11/16 by tball <[email protected]>
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=107959033
  • Loading branch information
tomball committed Nov 18, 2015
1 parent 8852c7c commit 4f6a2a3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions jre_emul/JreEmulation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
062463D41A000CE3006D52C9 /* JRETestsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 062463D31A000CE3006D52C9 /* JRETestsTableViewController.m */; };
062463DA1A005995006D52C9 /* JRELogPaneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 062463D91A005995006D52C9 /* JRELogPaneViewController.m */; };
06459FC71A4223F000F5ED23 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 06C54AD31A40C7A4004B3ACD /* libicucore.dylib */; };
064EDBEF1BF5580900D25A14 /* NSErrorExceptionTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 064EDBEE1BF5577000D25A14 /* NSErrorExceptionTest.m */; };
06574A1A1A8EAF0B000A3616 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06C73F5719180E64001D3CC8 /* Security.framework */; };
06574A1C1A8EAF84000A3616 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 06574A1B1A8EAF84000A3616 /* QuartzCore.framework */; };
06574A3D1A8EB04A000A3616 /* AlgorithmParametersSpiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 06574A1D1A8EB04A000A3616 /* AlgorithmParametersSpiTest.m */; };
Expand Down Expand Up @@ -1210,6 +1211,7 @@
0649A7BD1AE07A4500DE2494 /* XMLFilter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = XMLFilter.m; path = build_result/Classes/org/xml/sax/XMLFilter.m; sourceTree = "<group>"; };
0649A7BE1AE07A4500DE2494 /* XMLReader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = XMLReader.m; path = build_result/Classes/org/xml/sax/XMLReader.m; sourceTree = "<group>"; };
0649A7BF1AE07A4500DE2494 /* XmlSerializer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = XmlSerializer.m; path = build_result/Classes/org/xmlpull/v1/XmlSerializer.m; sourceTree = "<group>"; };
064EDBEE1BF5577000D25A14 /* NSErrorExceptionTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NSErrorExceptionTest.m; path = com/google/j2objc/net/NSErrorExceptionTest.m; sourceTree = "<group>"; };
064FB746172705F400DC0D51 /* URI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = URI.h; path = build_result/Classes/java/net/URI.h; sourceTree = "<group>"; };
064FB747172705F400DC0D51 /* URI.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = URI.m; path = build_result/Classes/java/net/URI.m; sourceTree = "<group>"; };
064FB74A172705F400DC0D51 /* URISyntaxException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = URISyntaxException.h; path = build_result/Classes/java/net/URISyntaxException.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6528,6 +6530,7 @@
06FADA7C1B3B29B300A9579E /* NoPackageTest.h */,
06FADA7D1B3B29B300A9579E /* NoPackageTest.m */,
06574A631A8EB150000A3616 /* NormalizerTest.m */,
064EDBEE1BF5577000D25A14 /* NSErrorExceptionTest.m */,
06E4E4F9197F1D46005DDE69 /* org */,
0615D3DB1BD83E7300132067 /* OtherBean.m */,
061AA0CC19FEF01800457D2B /* package-info.h */,
Expand Down Expand Up @@ -8217,6 +8220,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
064EDBEF1BF5580900D25A14 /* NSErrorExceptionTest.m in Sources */,
0600C0121B715D13005FDEF9 /* CreationReferenceTest.m in Sources */,
0600C0131B715D13005FDEF9 /* ExpressionMethodReferenceTest.m in Sources */,
0600C0141B715D13005FDEF9 /* Lambdas.m in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions jre_emul/Tests/java/lang/reflect/ReflectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.List;

import junit.framework.TestCase;

Expand All @@ -55,6 +56,13 @@ public NoEquals() {}
public NoEquals(String s) {}
}

static class ParameterizedReturnTest {
// Method that returns a parameterized type.
public List<String> getStringList() {
return null;
}
}

// Assert equals method can be found using reflection. Because it's a mapped
// method with a parameter, reflection was trying to find "equalsWithId:"
// instead of "isEqual:".
Expand Down Expand Up @@ -91,4 +99,9 @@ public void testNonDefaultConstructorAnnotations() {
}
}

public void testParameterizedTypeMethodReturn() throws Exception {
Method method = ParameterizedReturnTest.class.getMethod("getStringList");
Type returnType = method.getGenericReturnType();
assertTrue(returnType instanceof ParameterizedType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ private static String createTypeSignature(ITypeBinding type) {
}

private static boolean hasGenericSignature(IMethodBinding method) {
if (method.isGenericMethod() || method.getReturnType().isTypeVariable()) {
if (method.isGenericMethod() || method.getReturnType().isTypeVariable()
|| method.getReturnType().isParameterizedType()) {
return true;
}
for (ITypeBinding param : method.getParameterTypes()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,13 @@ public void testGenericTypeMetadata() throws IOException {
assertTranslation(translation,
"\"set_\", NULL, 0x0, \"Ljava.util.Set;\", NULL, \"Ljava/util/Set<TT;>;\",");
}

public void testMethodParameterizedReturnTypeMetadata() throws IOException {
String translation = translateSourceFile(
"import java.util.*; class Test { List<String> getStringList() { return null; }}",
"Test", "Test.m");

// Assert method metadata has generic return signature.
assertTranslation(translation, "\"()Ljava/util/List<Ljava/lang/String;>;\"");
}
}

0 comments on commit 4f6a2a3

Please sign in to comment.