Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trying to reach an object inside other

 
Alonso Tapia
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, this is my problem
Matbe it's not the best form to explain it, but i'll show the variables first:

I'm working with a Neural Networks library called Joone.
So i need to reach the FileInputSynapse object to easily change the input files.
With a couple of lines of code I can reach the input of my neural network object called nnet, that currently is an InputConnector object;

My problem is that the InputConnector class has no method to get its own inputs, although clearly the FileInputSynapse object it's inside InputConnector

so i'm stuck there, anyone can help please??
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You would either have to add methods allowing access to that field, or consider that whoever designed the class thought it was a bad idea to allow access to that field at all. Do you have any way to contact whoever designed the class, that you can ask why it is hidden?
 
Alonso Tapia
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to mail the author like 1 month ago for another thing but I never received an answer.
So it looks like I'll have to add methods, but can I do that to a compiled library .jar file??
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, you can't. But a filename wouldn't have been hard-coded into the class, so presumably it's on some properties file somewhere that you can alter.
 
Alonso Tapia
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well I can change the filename very easily the problem is that I can't get to the object that contains that property. That object has another properties too that usually I don't want to change
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really doesn't sound as it should be needed to go this way to change the input files for a library, but you can use reflection and methods like java.lang.reflect.AccessibleObject#setAccessible() to access anything.
 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But where does it get those properties from?
 
Alonso Tapia
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok this is the complete deal.
Joone means Java Object Oriented Neural Engine and it's composed by a library and the corresponding GUI. Any NN that I create in the GUI can be exported to a seralized file that can be restored from a custom java program and be manipulated from there so the NN can be used in a real practical application.
This is the NN that I'm currently using, created with the GUI:

The NN is composed by the blocks in the rectangle and the rest are the input-output blocks and connectors to change the input-output when the NN is under Training or Recall.
I really want to keep this structure because it simplifies the Traning & Recall phases necessary for the net to work properly. As you can see File Input has several properties and the only one I'll need to change eventually is InputFile. With I got access to the InputConnector of the left, the direct input to the net, but from that conector to the FileInput object it's what I can't realize how to...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49776
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I still think you are not supposed to gain access to that hidden field.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You wouldn't even know how the system reacts. Maybe it just ignores changes to the filename at runtime because the input nodes have been initialized already?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic