Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

how to generate warning from compiler?

Thread view: 
VisionSet - 19 Nov 2005 17:26 GMT
I am writing some classes that comply with java bean contract soI must
supply default constructor.
But *my* code should never call this constructor.  Is it possible to make
the compiler warn me if I inadvertantly call it?

--
Mike W
Thomas Fritsch - 19 Nov 2005 20:31 GMT
> I am writing some classes that comply with java bean contract soI must
> supply default constructor.
> But *my* code should never call this constructor.  Is it possible to make
> the compiler warn me if I inadvertantly call it?
You could put a "@deprecated" javadoc comment in front of it. For example:

 /**
  * Default constructor.
  * @deprecated  Do not use it!
  */
 public MyBean() {
 }

Signature

"TFritsch$t-online:de".replace(':','.').replace('$','@')

VisionSet - 19 Nov 2005 20:53 GMT
> > I am writing some classes that comply with java bean contract soI must
> > supply default constructor.
> > But *my* code should never call this constructor.  Is it possible to make
> > the compiler warn me if I inadvertantly call it?
> You could put a "@deprecated" javadoc comment in front of it. For example:

I wonder if any automatic use of beans would object to that?
Not that it will affect my case - just passing to JSP pages, and they don't
write beans.

--
Mike W
Roedy Green - 19 Nov 2005 21:36 GMT
On Sat, 19 Nov 2005 21:31:48 +0100, "Thomas Fritsch"
<i.dont.like.spam@invalid.com> wrote, quoted or indirectly quoted
someone who said :

>> I am writing some classes that comply with java bean contract soI must
>> supply default constructor.
>> But *my* code should never call this constructor.  Is it possible to make
>> the compiler warn me if I inadvertantly call it?

Are you allowed to make it private?  I guess beans need it for their
own XML-based serialization scheme.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.