wood burning stoves
The moose likes Java Micro Edition and the fly likes do j2me support finalize() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "do j2me support finalize()" Watch "do j2me support finalize()" New topic

do j2me support finalize()

vicky sandhu

Joined: Jun 21, 2005
Posts: 3
i m working on midp 1.0 and
cldc 1.0
it gives a problem when ever i try to build with finalize() in my program :-

"ERROR: finalize methods should not appear
Error preverifying class BarBall.MainMenu
com.sun.kvem.ktools.ExecutionException: Preverifier returned 1
Build failed"

plz help

BarBall is a package
and MainMenu is a class
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I think you got your answer in the Error.

You actually should avoid creating finalize methods in all of Java. You just never know when it will run, or in some cases it might have already run and will not run when it is actually garbaged.

There are many better solutions for any need to code in the finalize method.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231

CLDC configurations like you will find on most J2ME devices do not support finalizers. Check the CLDC JSRs. MIDP works on top of CLDC in most devices.

Also, it might not be a good idea to use it as general Java practice, like Mark Spritzler just said. Only if you want something very specific.

[ August 26, 2005: Message edited by: Eduardo Marques ]
[ August 26, 2005: Message edited by: Eduardo Marques ]

Eduardo Marques
Get ready for your SCMAD certification at J2MECertificate.com - See what all the buzz is about ...
Marwan Zeineddine

Joined: Nov 04, 2009
Posts: 1
CLDC Spec JSR 30 section 4.2

CLDC libraries do not include the method Object.finalize(), and therefore a JVM supporting CLDC shall not support finalization of class instances (JLS sec 12.6). No application built on top of a JVM supporting CLDC shall require tha tifnalization is available.

I agree. Here's the link: http://aspose.com/file-tools
subject: do j2me support finalize()
jQuery in Action, 3rd edition