Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Compiler-Bug: "The local variable oResult may not have been initialized"
Compiler-Bug: "The local variable oResult may not have been initialized" [message #108454] Tue, 21 October 2003 22:35 Go to next message
Eclipse UserFriend
Hello,

I believe I found a Java compiler bug in Eclipse M4 (my fifth or so ;-);
see the method "badUninitializedVariableErrorMessage()" in the example
below.

/**
* class CompileError
*/
public class CompileError {
private static final class MethodProvider {
// If you remove the 'throws Exception': The error Message disapears
public Object openAppletJarOf(Object o) throws Exception {
return null;
}
}
/**
* This method compiles with a Compiler Error:
* "The local variable oResult may not have been initialized"
* Question: Why?
*/
public static Object badUninitializedVariableErrorMessage(//
) throws Exception {
final MethodProvider oMethodProvider = new MethodProvider();
final boolean bFlag1 = !true, bFlag2 = !true;
// If you uncomment the next if-else: The error Message disapears
if (!bFlag1) {
final Object o2 = null;
} else {
final Object o2 = oMethodProvider.openAppletJarOf(null);
}
final Object oResult, o1 = null;
if (o1 != null) {
oResult = null;
oMethodProvider.openAppletJarOf(null);
} else {
// If you uncomment the next line: The error Message disapears
final Object o4 = oMethodProvider.openAppletJarOf(null);
oResult = null;
}
return oResult;
}
}


Kind Regards

Mle
Re: Compiler-Bug: "The local variable oResult may not have been initialized" [message #108580 is a reply to message #108454] Wed, 22 October 2003 04:29 Go to previous messageGo to next message
Eclipse UserFriend
Please file a bug report against JDT/Core.

Sebastian
Re: Compiler-Bug: "The local variable oResult may not have been initialized" [message #108756 is a reply to message #108454] Wed, 22 October 2003 08:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomann.ca.ibm.comNOSPAM

Thanks, I entered https://bugs.eclipse.org/bugs/show_bug.cgi?id=45365
--
Olivier
Re: Compiler-Bug: "The local variable oResult may not have been initialized" [message #110753 is a reply to message #108454] Mon, 27 October 2003 05:00 Go to previous message
Eclipse UserFriend
fyi - a patch is available to correct this defect, please find it at:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/jdt- core-home/r3.0/m
ain.html#updates
or wait for the next integration build...

"mle" <mle@neze.de> wrote in message news:bn4r52$9d$1@eclipse.org...
> Hello,
>
> I believe I found a Java compiler bug in Eclipse M4 (my fifth or so ;-);
> see the method "badUninitializedVariableErrorMessage()" in the example
> below.
>
> /**
> * class CompileError
> */
> public class CompileError {
> private static final class MethodProvider {
> // If you remove the 'throws Exception': The error Message disapears
> public Object openAppletJarOf(Object o) throws Exception {
> return null;
> }
> }
> /**
> * This method compiles with a Compiler Error:
> * "The local variable oResult may not have been initialized"
> * Question: Why?
> */
> public static Object badUninitializedVariableErrorMessage(//
> ) throws Exception {
> final MethodProvider oMethodProvider = new MethodProvider();
> final boolean bFlag1 = !true, bFlag2 = !true;
> // If you uncomment the next if-else: The error Message disapears
> if (!bFlag1) {
> final Object o2 = null;
> } else {
> final Object o2 = oMethodProvider.openAppletJarOf(null);
> }
> final Object oResult, o1 = null;
> if (o1 != null) {
> oResult = null;
> oMethodProvider.openAppletJarOf(null);
> } else {
> // If you uncomment the next line: The error Message disapears
> final Object o4 = oMethodProvider.openAppletJarOf(null);
> oResult = null;
> }
> return oResult;
> }
> }
>
>
> Kind Regards
>
> Mle
Previous Topic:How to change the default type to java after importing project
Next Topic:add wizard to drop down menu
Goto Forum:
  


Current Time: Tue Oct 28 18:03:06 EDT 2025

Powered by FUDForum. Page generated in 0.05604 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top