473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Accessing a private object

There is a private object in a closed-source class that I need to get
access to.
Is there any tips or tricks to accomplish that?

Jul 17 '05 #1
4 3579
nope...
--
----------------------------------------------------------
.......vieni a trovarmi http://www.glz.it
.......novitą java, forum e altro http://www.javastaff.com
----------------------------------------------------------

------dai voce al tuo sito e monitorizza gli accessi------
---------------http://www.talkwithus.it-------------------
----------------------------------------------------------
Jul 17 '05 #2
On 1 Mar 2005 20:43:44 -0800, javidz wrote:
There is a private object in a closed-source class that I need to
get access to. Is there any tips or tricks to accomplish that?


Certainly JNI isn't bothered by normal access rules.

You could also have a look at java.lang.reflect.ReflectPermission,
which seems to support the use of reflection for what you're trying to
do.

/gordon

--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Jul 17 '05 #3

javidz wrote:
There is a private object in a closed-source class that I need to get
access to.
Is there any tips or tricks to accomplish that?


First of all you should contact the autor of the code. He/She has a
reason to make that private, and should provide a way for you to use
that object if it is suposed to be like that. Maybe he/she could
provide you either a way or a patch.

Still as some1 said you could work with java.lang.reflect, I had
something similar to this. But it was my code, and I still wanted to
let them as private fields. What i did was making my second class be in
the same package, and that let me use reflection a little, and i manage
to acomplish what i wanted. I don't know what you need so i can't give
more details.

BUT remenber the 1st thing you should do is find a "proper way", use
reflection as your last resource, since it's real purpose is to create
objects in runtime from which you don't know the type in compile time.

Jul 17 '05 #4
javidz wrote:
There is a private object in a closed-source class that I need to get
access to.
Is there any tips or tricks to accomplish that?


Use Class.getDeclaredField to get a java.lang.reflect.Field reference to
the object; then call field.setAccessible(true).
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: red | last post by:
If I use PEAR to produce an accociative array from a mysql table, and display the array with print_r, it says it is an array and it displays values like a regular array: Array ( => 1 =>...
11
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
5
by: Sandeep | last post by:
Hi, In the following code, I wonder how a private member of the class is being accessed. The code compiles well in Visual Studio 6.0. class Sample { private: int x; public:
6
by: Alfred B. Thordarson | last post by:
I have a problem accessing a DLL using C#. I'm using C/FRONT with Navision's CFRONT.DLL, which contains the method: DBL_S32* DBL_NextKey(DBL_HTABLE hTable, DBL_S32* Key); typedef signed long...
6
by: TB | last post by:
I understand the basics of finalization and implementing IDisposable and how one is guaranteed access to managed objects only when working through the IDisposable interface. My question is to what...
3
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
2
by: damonf | last post by:
I'm currently trying to add an ASP hyperlink to a template column in a datagrid. The normal hyperlink column doesn't give me the ability to add attributes to the item. In my grid there are four...
3
by: DotNetNewbie | last post by:
I am reading the book Teach Yourself Microsoft Visual Basic .Net 2003 in 21 Days. I am having trouble getting one of the exercises to work at the end of day 4. Exercises: 1. Create a new...
3
by: Olivier BESSON | last post by:
Hello, I have a web service of my own on a server (vb.net). I must declare it with SoapRpcMethod to be used with JAVA. This is a simple exemple method of my vb source : ...
0
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.