RFR: 8257740: Compiler crash when compiling type annotation on multicatch inside lambda [v2]

Guoxiong Li github.com+13688759+lgxbslgx at openjdk.java.net
Thu Jan 7 21:24:56 UTC 2021


On Thu, 7 Jan 2021 19:12:13 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

>> looks good to me
>
> @vicente-romero-oracle Thank you for your review. Could I get your help to sponsor this patch? Thanks again.

Because `VarSymbol.data` is private, currently I need to do it as below.

// way 1
if (((VarSymbol) sym).isExceptionParameter()) {
    ((VarSymbol) ret).setData(ElementKind.EXCEPTION_PARAMETER);
}
if (((VarSymbol) sym).isResourceVariable()) {
    ((VarSymbol) ret).setData(ElementKind.RESOURCE_VARIABLE);
}

If we revise `VarSymbol.data` to public, we can do it as below.

// way 2
// class VarSymbol
public Object data;

// Usage
 ((VarSymbol) ret).data = ((VarSymbol) sym).data;

Or we can provide a method to get `VarSymbol.data`, the corresponding code is shown below.

// way 3
// class VarSymbol
public Object getData() {
    return this.data;
}

// Usage
((VarSymbol) ret).setData(((VarSymbol) sym).getData());

In my opinion, way 3 is better. Which way do you think is the best way?

-------------

PR: https://git.openjdk.java.net/jdk/pull/1648


More information about the compiler-dev mailing list