Cannot access 'password': it is public/*package*/ for synthetic extension in '<library Maven: com.microsoft.sqlserver:mssql-jdbc:10.2.0.jre17>'
There is no error on url or user; only on password. If I replace it with
sqlServerDataSource.setPassword(myPassword)
it works. But why can't I use the property syntax, and what exactly does the error message mean, and why only password has this error?
Klitos Kyriacou
04/14/2022, 9:08 AM
It turns out that this seems to be caused by the Java class SQLServerDataSource having
public void setPassword(String password)
but only a package-private
String getPassword()
. This prevents Kotlin from synthesizing a
password
property.
Is this intentional, or is it a bug?
m
Michael de Kaste
04/14/2022, 9:24 AM
It's definitely a weird visibility way sqlServerDataSource uses since it's literally impossible to recreate the same scenario in kotlin; this the field cannot be mapped properly to kotlin accessibility
Michael de Kaste
04/14/2022, 9:24 AM
image.png
Michael de Kaste
04/14/2022, 9:25 AM
so it seems that setPassword and getPassword should be actual functions you should access in kotlin as well. The fact you can directly access a "password" field is a bug I would say