diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
index 36ab4a145f991..886da9fd6ba5a 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java
@@ -1018,7 +1018,11 @@ private Attribute.TypeCompound toTypeCompound(Attribute.Compound a, TypeAnnotati
                     if (!invocation.typeargs.contains(tree)) {
                         return TypeAnnotationPosition.unknown;
                     }
-                    MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect());
+                    Symbol exsym = TreeInfo.symbol(invocation.getMethodSelect());
+                    if (exsym.type.isErroneous()) {
+                        // bail out, don't deal with erroneous types which would be reported anyways
+                        return TypeAnnotationPosition.unknown;
+                    }
                     final int type_index = invocation.typeargs.indexOf(tree);
                     if (exsym == null) {
                         throw new AssertionError("could not determine symbol for {" + invocation + "}");
diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.java b/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.java
new file mode 100644
index 0000000000000..da2174640d989
--- /dev/null
+++ b/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.java
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8334756
+ * @summary javac crashes on call to non-existent generic method with explicit annotated type arg
+ * @compile/fail/ref=CrashOnNonExistingMethodTest.out -XDrawDiagnostics -XDdev CrashOnNonExistingMethodTest.java
+ */
+
+import static java.lang.annotation.ElementType.TYPE_USE;
+import java.lang.annotation.Target;
+
+class CrashOnNonExistingMethodTest {
+    @Target(TYPE_USE)
+    @interface Nullable {}
+
+    static <T extends @Nullable Object> T identity(T t) {
+        return t;
+    }
+
+    static void test() {
+        CrashOnNonExistingMethodTest.<@Nullable Object>nonNullIdentity(null);
+    }
+}
diff --git a/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.out b/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.out
new file mode 100644
index 0000000000000..376c06c93b037
--- /dev/null
+++ b/test/langtools/tools/javac/annotations/typeAnnotations/CrashOnNonExistingMethodTest.out
@@ -0,0 +1,2 @@
+CrashOnNonExistingMethodTest.java:20:37: compiler.err.cant.resolve.location.args.params: kindname.method, nonNullIdentity, java.lang.Object, compiler.misc.type.null, (compiler.misc.location: kindname.class, CrashOnNonExistingMethodTest, null)
+1 error