The Artima Developer Community
Sponsored Link

Java Buzz Forum
Hacking 'Package Protected' variables in a Java Class

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Goldy Lukka

Posts: 1008
Nickname: xyling
Registered: Jan, 2004

Goldy Lukka is a Java Developer and an Entrepreneur. He is Founder of xyling.com.
Hacking 'Package Protected' variables in a Java Class Posted: May 28, 2004 2:11 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Goldy Lukka.
Original Post: Hacking 'Package Protected' variables in a Java Class
Feed Title: Xyling Java Blogs
Feed URL: http://www.javablogs.xyling.com/thisWeek.rss
Feed Description: Your one stop source for Java Related Resources.
Latest Java Buzz Posts
Latest Java Buzz Posts by Goldy Lukka
Latest Posts From Xyling Java Blogs

Advertisement
Is this a normal behaviour or a security issue?
Recently, while working on my J2ME based project, I had to create my own TextField with some added features like a cursor. I planned extending the TextField class (package javax.microedition.lcdui) and add my own behaviour. But!! the members keyPressed, keyRelease and graphics object were all package protected.
I desperately needed this behaviour and thought of one trick. I made MyTextField Class being in the package javax.microedition.lcdui (of course by the package declaration statement). And VOILA! it worked well....

So the next time whenever you need to excess any package protected variables (even if they belong to VM core classes) just put your class in the same package name.

ENJOY!!!

[Resource-Type: Tip; Category: Java/All]

Read: Hacking 'Package Protected' variables in a Java Class

Topic: [May 19, 2004 13:55 PDT] 14 Links Previous Topic   Next Topic Topic: 1 Terabyte of Gmail

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use