inner class question

M

Mullin

i got compilation error:
[javac] C:\opt\SVGT\Development\src\java\hk\com\smartone\svgtx\converter\Con
verter.java:104: local variable jpegConverted is accessed from within
inner clas
s; needs to be declared final
[javac] jpegConverted =
objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile)
(objObj
ect)));

as jpegConverted, _objAttachment, sExtension, objObject are outer
class variables and some functions of outer class may need to get and
set their values and can't assign those variables to final.

any methods to solve this?

try {
/* original code
objLog.info("before convert");
jpegConverted = objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile)
(objObject)));
objLog.info("after convert");
*/
//
Thread th = new Thread()
{
public void run()
{
objLog.info("before convert");
jpegConverted =
objConvertService.convert(_objAttachment.getData(),sExtension,"JPEG",((docconv.service.ImageProfile)
(objObject)));
objLog.info("after convert");
}
};
th.start();
th.join(100 * 1000);
if(th.isAlive())
{
th.interrupt();
throw new Exception("Timeout");
}
//
} catch(Exception _objException) {
objLog.err(sContentName + ": Others Exception returned by
transcoder.",_objException);
convertSuccess = false;
}
 
F

Fred

If the semantics hold for your particular function, you can always do:

final <_objAttachment.getData() type> attachData=
_objAttachment.getData();
final <sExension type> attachExt = sExtension;
final docconv.service.ImageProfile attachObj = objObject;

jpegConverted =
objConvertService.convert( attachData, attachExt,"JPEG",attachObj);
 
S

Skip

Fred said:
If the semantics hold for your particular function, you can always do:

final <_objAttachment.getData() type> attachData=
_objAttachment.getData();
final <sExension type> attachExt = sExtension;
final docconv.service.ImageProfile attachObj = objObject;

jpegConverted =
objConvertService.convert( attachData, attachExt,"JPEG",attachObj);

or create a method in the class returning the value, called by the
inner-class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top