-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
  • 7,420
  • 4
  • 53
  • 63
R.S.
  • 367
  • 2
  • 14
  • 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
  • 7,420
  • 4
  • 53
  • 63
Andronicus
  • 25,419
  • 17
  • 47
  • 88
  • 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