Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Illegal Access Exception

 
Greenhorn
Posts: 7
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When does this illegal access exception arise? I don't face it when i use NETBEANS IDE but when i upload the solution it doesnot support test parameters and the error is illegal access exception..



can you please explain why in general this illegal access exception is encountered? and do i have a way to find out which part of the code might have caused the exception. i mean is there a way to catch the illegal access exception.
The online API has some vague information but i absolutely have no idea as to what it means..
Illegal access exception java API
 
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is not enough information here. Post the entire error message. Try to write as small a program (or at least a class) as will produce the error. You have told us what the error is in general but not your specific output of it, and the code you've listed would not produce the error by itself (even if it were in a complete class).
 
Greenhorn
Posts: 12
Eclipse IDE Redhat Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Harsha
Yes, Ralph is right. You need to give some more information about your problem. It will help us to identify the problem and assist you.
 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch, Sree Harsha Subraveti!

The online API has some vague information but i absolutely have no idea as to what it means..


It says if your code tries to create an instance/access any field through Java reflection which the caller does not have access to the particular class/field it may result this exception.

Can you explain/show your code which throws the exception and the any related code it uses.
 
sree harsha subraveti
Greenhorn
Posts: 7
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey actually it's my solution to topcoder. I just couldnot understand where this illegal access exception is occuring.. it's a bit of clumsy code. This works well on Netbeans 7.0 IDE


can you tell me where this multiple instances thingy happens..
 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but when i upload the solution it doesnot support test parameters and the error is illegal access exception..


My initial thought was something wrong with the program. But it looks like the site/simulator you are using has some issues with your code. Perhaps it expects some test method to be present to execute? Have you checked what is expected by that?
 
sree harsha subraveti
Greenhorn
Posts: 7
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the code works fine. The simulator shows me to keep dat pointVal method public. and i did it. yet the test parameters are not accepted.

i should have emphasized that the code works fine.
I am just confused if any field or parameters have caused the illeagalaccessexception. infact, the code compiles successfully..
 
sree harsha subraveti
Greenhorn
Posts: 7
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in my case, i could resolve the problem by declaring the class public. Thanks for the help.

if class is not declared public, it is package-private apparently..
 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if class is not declared public, it is package-private apparently..


Yes, it is.
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic