-
Notifications
You must be signed in to change notification settings - Fork 74
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
Linkage Checker to verify method references to JRE classes #1607
Changes from all commits
ab53f2e
a8a1571
a36b452
f0f81dc
8199078
8a9dca3
baeaa93
82a0837
b494064
12c0fe1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,8 +239,7 @@ Optional<LinkageProblem> findLinkageProblem( | |
String targetClassName = symbol.getClassBinaryName(); | ||
String methodName = symbol.getName(); | ||
|
||
// Skip references to Java runtime class. For example, java.lang.String. | ||
if (classDumper.isSystemClass(targetClassName)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was hiding the protobuf's linkage error against Java 8 runtime protocolbuffers/protobuf#7827 |
||
if (ClassDumper.isArrayClass(targetClassName)) { | ||
return Optional.empty(); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,62 @@ | |
<Package name="org.graalvm" /> | ||
</Source> | ||
</LinkageError> | ||
|
||
<LinkageError> | ||
<Target> | ||
<Class name="java.lang.invoke.MethodHandle" /> | ||
</Target> | ||
<Source> | ||
<Package name="com.oracle.svm" /> | ||
</Source> | ||
<Reason> | ||
GraalVM-related libraries depend on Java Compiler Interface (JVMCI) that | ||
only exists in special JDK. These missing classes are false positives, because | ||
the code is only invoked when running in a GraalVM. | ||
https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/929 | ||
</Reason> | ||
</LinkageError> | ||
<LinkageError> | ||
<Target> | ||
<Class name="java.lang.invoke.MethodHandle" /> | ||
</Target> | ||
<Source> | ||
<Package name="com.oracle.graal" /> | ||
</Source> | ||
<Reason> | ||
GraalVM-related libraries depend on Java Compiler Interface (JVMCI) that | ||
only exists in special JDK. These missing classes are false positives, because | ||
the code is only invoked when running in a GraalVM. | ||
https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/929 | ||
</Reason> | ||
</LinkageError> | ||
<LinkageError> | ||
<Target> | ||
<Class name="java.lang.invoke.MethodHandle" /> | ||
</Target> | ||
<Source> | ||
<Package name="org.graalvm" /> | ||
</Source> | ||
<Reason> | ||
GraalVM-related libraries depend on Java Compiler Interface (JVMCI) that | ||
only exists in special JDK. These missing classes are false positives, because | ||
the code is only invoked when running in a GraalVM. | ||
https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/929 | ||
</Reason> | ||
</LinkageError> | ||
<LinkageError> | ||
<Target> | ||
<Class name="java.lang.invoke.MethodHandle" /> | ||
</Target> | ||
<Source> | ||
<Package name="com.oracle.truffle" /> | ||
</Source> | ||
<Reason> | ||
GraalVM-related libraries depend on Java Compiler Interface (JVMCI) that | ||
only exists in special JDK. These missing classes are false positives, because | ||
the code is only invoked when running in a GraalVM. | ||
https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/929 | ||
</Reason> | ||
</LinkageError> | ||
Comment on lines
+44
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because now we check JDK classes, GraalVM-related exclusion is needed. |
||
<LinkageError> | ||
<Target> | ||
<Class name="org.mockito.internal.creation.bytebuddy.MockMethodDispatcher" /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1120,4 +1120,24 @@ public void testFindLinkageProblems_grpcAndGuava() throws IOException { | |
"has class binary name")) | ||
.contains("io.grpc.internal.DnsNameResolver"); | ||
} | ||
|
||
@Test | ||
public void testFindLinkageProblems_referenceToJava11Method() throws IOException { | ||
// protobuf-java 3.12.4 references a Java 11 method that does not exist in Java 8 | ||
// https://github.com/protocolbuffers/protobuf/issues/7827 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is Kristen's finding yesterday. |
||
ImmutableList<ClassPathEntry> jars = | ||
TestHelper.resolve("com.google.protobuf:protobuf-java:3.12.4"); | ||
|
||
LinkageChecker linkageChecker = LinkageChecker.create(jars); | ||
ImmutableSet<LinkageProblem> linkageProblems = linkageChecker.findLinkageProblems(); | ||
|
||
MethodSymbol methodSymbol = | ||
new MethodSymbol("java.nio.CharBuffer", "flip", "()Ljava/nio/CharBuffer;", false); | ||
|
||
SymbolNotFoundProblem expectedProblem = | ||
new SymbolNotFoundProblem( | ||
new ClassFile(jars.get(0), "com.google.protobuf.TextFormat"), null, methodSymbol); | ||
|
||
Truth.assertThat(linkageProblems).contains(expectedProblem); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will we catch a reference to an array of a missing class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but not from array class reference. When there's a reference to array of a class, there should be a reference to the class in the same class file.