Upgrading to 2018.1 has caused all my public static final constants to have compiler errors

Answered

All my classes that have public static final String NAME = "value" are now getting an error. I know this code should be adjusted but there is a lot due to historical reasons and it's not something I want to refactor right now. Before upgrading today it was fine. How do I resolve this error since it's valid Java without having to take the time to refactor it all.

I also tried to see if it was an error with the file itself so I manually retyped it in for a few lines and it was the same result, so it's not a file corruption issue but an error. 

This has basically stopped me from being able to work so any help would be greatly appreciated!!

Attached is a screenshot

 

0
11 comments

More details. It appears to only affect constants that end with _COL

0

It seems to only affect constants that are referenced in SQL code

0

 

It looks like it only affects constants that are used in SQL queries. 

 

 

That being said I apologize but I'm not sure what you're referring to Serge. I don't see any option to un-inject...

0

See the link. Alt+Enter inside the string.

0

I don't have that option. Attached is a screenshot

 

0

That option only seems to appear on constants that aren't used in SQL queries.

0

Below is the code in case it helps:

 

public class PeopleSQL
{
public static final String ID_COL = "id";
public static final String FIRSTNAME_COL = "firstname";
public static final String LASTNAME_COL = "lastname";

public static void getListOfPeople(Connection connection) throws RanaSQLException
{
PreparedStatement statement = null;
ResultSet result = null;

try
{
statement = connection.prepareStatement("SELECT " + ID_COL + ", " + LASTNAME_COL + " FROM people");
result = statement.executeQuery();

} catch (SQLException e) {
e.printStackTrace();
} finally {
try
{
result.close();
statement.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}

class People
{

}

 

 

0

It appears to be a bug, as a workaround you can disable this injection: https://i.imgur.com/bUS579f.png.

1

Thank you, I've just disabled it until the bug is fixed. 

I also submitted a ticket but haven't gotten a response. When I get a response I'll point them to here. 

 

 

0

Please sign in to leave a comment.