Skip to content
Advertisement

Extension private field in java

I read the Spring Data source and meet a question: JdbcTemplate has a method:

JavaScript

and I find that this.dataSource is from it`s father class JdbcAccessor.declearing as follow

JavaScript

my question is: why extension class JdbcTemplate can access its father class`s private field? I try to use it as follow and find IDE show its wrong

JavaScript

Advertisement

Answer

It can not. Most likely you used some sort of decompiler which couldn’t properly decompile it. The actual code is like this in JDBCTemplate

JavaScript

And setDatasource method is in JDBCAccessor.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement