Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -798,11 +798,10 @@ public JavaField lookupField(int rawIndex, ResolvedJavaMethod method, int opcode
HotSpotResolvedObjectTypeImpl resolvedHolder;
try {
resolvedHolder = compilerToVM().resolveFieldInPool(this, rawIndex, (HotSpotResolvedJavaMethodImpl) method, (byte) opcode, info);
} catch (Throwable t) {
resolvedHolder = null;
} catch (Throwable cause) {
return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type, cause);
}
if (resolvedHolder == null) {
// There was an exception resolving the field or it returned null so return an unresolved field.
return new UnresolvedJavaField(fieldHolder, lookupUtf8(getNameRefIndexAt(nameAndTypeIndex)), type);
}
final int flags = info[0];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,10 +31,27 @@ public final class UnresolvedJavaField implements JavaField {
private final JavaType holder;
private final JavaType type;

public UnresolvedJavaField(JavaType holder, String name, JavaType type) {
/**
* The reason field resolution failed. Can be null.
*/
private final Throwable cause;

public UnresolvedJavaField(JavaType holder, String name, JavaType type, Throwable cause) {
this.name = name;
this.type = type;
this.holder = holder;
this.cause = cause;
}

public UnresolvedJavaField(JavaType holder, String name, JavaType type) {
this(holder, name, type, null);
}

/**
* Gets the exception, if any, representing the reason field resolution resulted in this object.
*/
public Throwable getCause() {
return cause;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -31,10 +31,27 @@ public final class UnresolvedJavaMethod implements JavaMethod {
private final Signature signature;
protected JavaType holder;

public UnresolvedJavaMethod(String name, Signature signature, JavaType holder) {
/**
* The reason method resolution failed. Can be null.
*/
private final Throwable cause;

public UnresolvedJavaMethod(String name, Signature signature, JavaType holder, Throwable cause) {
this.name = name;
this.holder = holder;
this.signature = signature;
this.cause = cause;
}

public UnresolvedJavaMethod(String name, Signature signature, JavaType holder) {
this(name, signature, holder, null);
}

/**
* Gets the exception, if any, representing the reason method resolution resulted in this object.
*/
public Throwable getCause() {
return cause;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,34 +28,54 @@
public final class UnresolvedJavaType implements JavaType {
private final String name;

/**
* The reason type resolution failed. Can be null.
*/
private final Throwable cause;

@Override
public String getName() {
return name;
}

private UnresolvedJavaType(String name) {
private UnresolvedJavaType(String name, Throwable cause) {
this.name = name;
this.cause = cause;
assert name.length() == 1 && JavaKind.fromPrimitiveOrVoidTypeChar(name.charAt(0)) != null || name.charAt(0) == '[' || name.charAt(name.length() - 1) == ';' : name;
}

/**
* Creates an unresolved type for a valid {@link JavaType#getName() type name}.
*/
public static UnresolvedJavaType create(String name) {
return new UnresolvedJavaType(name);
return new UnresolvedJavaType(name, null);
}

/**
* Creates an unresolved type for a valid {@link JavaType#getName() type name}.
*/
public static UnresolvedJavaType create(String name, Throwable cause) {
return new UnresolvedJavaType(name, cause);
}

/**
* Gets the exception, if any, representing the reason type resolution resulted in this object.
*/
public Throwable getCause() {
return cause;
}

@Override
public JavaType getComponentType() {
if (getName().charAt(0) == '[') {
return new UnresolvedJavaType(getName().substring(1));
return new UnresolvedJavaType(getName().substring(1), null);
}
return null;
}

@Override
public JavaType getArrayClass() {
return new UnresolvedJavaType('[' + getName());
return new UnresolvedJavaType('[' + getName(), null);
}

@Override
Expand Down