-1

Using the @Autowired annotation, I've managed to succesfully call the methods i needed from another class, however not all of them, since some methods are private.

Is it possible to call them without making them public? How?

Hearen
  • 6,951
  • 2
  • 47
  • 57
R.S.
  • 357
  • 1
  • 10
  • see using reflection possible but not recommended. https://stackoverflow.com/questions/880365/any-way-to-invoke-a-private-method – Akash Shah Mar 11 '19 at 10:29

1 Answers1

0

You cannot do that. Dependency injection is just a trick, that takes handling of interfaces and implementations from developer. Framework is doing that for you. The resulting object has same properties as if it was created using new keyword.

Hearen
  • 6,951
  • 2
  • 47
  • 57
Andronicus
  • 24,333
  • 17
  • 47
  • 82
  • So the only way to access them is to make them public in the original class? Could i use reflection or other techniques? – R.S. Mar 11 '19 at 10:28