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

Vicente Romero vromero at openjdk.java.net
Fri Jan 8 13:58:54 UTC 2021


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

> 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?

NVM, what you already did is the best way for now, we prefer to keep the `data` field private, sorry for the noise and thanks again for the good job

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

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


More information about the compiler-dev mailing list