Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not accurately convert diagnostic (compiler.err.record.cannot.declare.instance.fields) #986

Open
mickaelistria opened this issue Nov 27, 2024 · 0 comments

Comments

@mickaelistria
Copy link

eg

Could not accurately convert diagnostic (compiler.err.record.cannot.declare.instance.fields)
/home/mistria/workspace/sandboxJava/src/sandboxJava/RGB.java: error: field declaration must be static
	public int red;
	           ^
  (consider replacing field with record component)

for eg

public record RGB(int red, int green, int blue) implements Serializable {

	/**
	 * the red component of the RGB
	 */
	public int red;

	/**
	 * the green component of the RGB
	 */
	public int green;

	/**
	 * the blue component of the RGB
	 */
	public int blue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant