wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Trying to reach an object inside other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Trying to reach an object inside other" Watch "Trying to reach an object inside other" New topic
Author

Trying to reach an object inside other

Alonso Tapia
Greenhorn

Joined: May 12, 2011
Posts: 12
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

Joined: Oct 13, 2005
Posts: 37902
    
  22
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

Joined: May 12, 2011
Posts: 12
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

Joined: Jan 06, 2011
Posts: 441

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

Joined: May 12, 2011
Posts: 12
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

Joined: Nov 18, 2008
Posts: 433
    
    2
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

Joined: Jan 06, 2011
Posts: 441

But where does it get those properties from?
Alonso Tapia
Greenhorn

Joined: May 12, 2011
Posts: 12
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

Joined: Oct 13, 2005
Posts: 37902
    
  22
I still think you are not supposed to gain access to that hidden field.
Hauke Ingmar Schmidt
Rancher

Joined: Nov 18, 2008
Posts: 433
    
    2
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?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Trying to reach an object inside other
 
Similar Threads
Questions About Being Static
Finalize() and GC
Runtime.getRuntime().exec() in a Servlet executing another java class
inhertiance question
form.action in IE