|
39 | 39 | import org.graalvm.compiler.phases.OptimisticOptimizations; |
40 | 40 | import org.graalvm.compiler.word.WordTypes; |
41 | 41 |
|
| 42 | +import com.oracle.graal.pointsto.constraints.TypeInstantiationException; |
42 | 43 | import com.oracle.graal.pointsto.constraints.UnresolvedElementException; |
43 | 44 | import com.oracle.svm.core.option.SubstrateOptionsParser; |
44 | 45 | import com.oracle.svm.core.util.UserError; |
@@ -155,6 +156,22 @@ protected JavaType maybeEagerlyResolve(JavaType type, ResolvedJavaType accessing |
155 | 156 | } |
156 | 157 | } |
157 | 158 |
|
| 159 | + @Override |
| 160 | + protected void handleIllegalNewInstance(JavaType type) { |
| 161 | + /* |
| 162 | + * If --allow-incomplete-classpath is set defer the error reporting to runtime, |
| 163 | + * otherwise report the error during image building. |
| 164 | + */ |
| 165 | + if (allowIncompleteClassPath) { |
| 166 | + ExceptionSynthesizer.throwException(this, InstantiationError.class, type.toJavaName()); |
| 167 | + } else { |
| 168 | + String message = "Cannot instantiate " + type.toJavaName() + |
| 169 | + ". To diagnose the issue you can use the " + allowIncompleteClassPathOption() + |
| 170 | + " option. The instantiation error is then reported at run time."; |
| 171 | + throw new TypeInstantiationException(message); |
| 172 | + } |
| 173 | + } |
| 174 | + |
158 | 175 | @Override |
159 | 176 | protected void handleUnresolvedNewInstance(JavaType type) { |
160 | 177 | handleUnresolvedType(type); |
@@ -255,12 +272,15 @@ private void handleUnresolvedMethod(JavaMethod javaMethod) { |
255 | 272 |
|
256 | 273 | private static void reportUnresolvedElement(String elementKind, String elementAsString) { |
257 | 274 | String message = "Discovered unresolved " + elementKind + " during parsing: " + elementAsString + |
258 | | - ". To diagnose the issue you can use the " + |
259 | | - SubstrateOptionsParser.commandArgument(NativeImageOptions.AllowIncompleteClasspath, "+") + |
| 275 | + ". To diagnose the issue you can use the " + allowIncompleteClassPathOption() + |
260 | 276 | " option. The missing " + elementKind + " is then reported at run time when it is accessed the first time."; |
261 | 277 | throw new UnresolvedElementException(message); |
262 | 278 | } |
263 | 279 |
|
| 280 | + private static String allowIncompleteClassPathOption() { |
| 281 | + return SubstrateOptionsParser.commandArgument(NativeImageOptions.AllowIncompleteClasspath, "+"); |
| 282 | + } |
| 283 | + |
264 | 284 | @Override |
265 | 285 | protected void emitCheckForInvokeSuperSpecial(ValueNode[] args) { |
266 | 286 | /* Not implemented in SVM (GR-4854) */ |
|
0 commit comments