My compiler is executing unreachable code !
Greetings
I have an if - else statement such as :
if (....)
{ for (...)
....return
} // end if
else {
... return
} end else
return something; // unreachableI'm executing a loop 10 times, and at 5, 6 and 7. the unreahable section is executed!
My question is : when does this happens? and how to prevent it?
knowing that removing the unreachable return statement will result in a missing return statement while compiling
First of all I want to thank you ...
ok here is my method
public int getPoints(int i, int m, boolean [] wrong, int [] array, int [] key, int correctPoints, int falsePoints)
if (wrong [m-1] == false)
for(int j = i; j < i + 4; j++)
if (array[j] < 220 )
if ( key[j] < 220)
return correctPoints;
else
return falsePoints
else
return falsePoints;
return -1; // shouldn't be reached I will try as BIJ001 did. that is eliminate the else. but I am still confused about the reason why -1 is returned.
Similar Messages
-
Compiler not reporting unreachable code
I had obvious bug code after return, but compiler did not
even reported an error should not it flag it as unreachable code?)
is that normal?It works as long as I delete all the class files each time, but that still doesn't explain why it's not recognizing the fact that it ought to recompile these classes every time. I've tried this on two different machines with two different operating systems, so it's not the environment. I've moved them, one file at a time, to brand new directories and the problem persists, so it's not any hidden files mucking things up. I don't even have a defined classpath. It has to be something intrinsic in these classes, and I'll be damned if I can figure out what.
-
Generate, compile, load, execute code on-the-fly
Hi,
I'd like to make something that:
- 1) Generates Java source code (this I can do)
- 2) Compiles this generated source code (I found an unsatisfying solution)
- 3) Loads the newly created classes (I'm stuck here)
- 4) Executes them in this very same program. (That should be trivial once the classes are loaded)
The solution I found for 2) is to invoke the compiler through Runtime.exec(). Isn't there a more integrated solution ?
And for 3), I think there is something to do with a ClassLoader or so, I'll try to figure it out on my own in the meantime.
Thank you,
The Ultimate Koalasee maybe Jakarta BCEL on : http://jakarta.apache.org/bcel/index.html and : http://jakarta.apache.org/bcel/manual.html (Byte Code Engineering Library)
-
Defect: Compiler wrongly complains about unreachable code.
Here is a packaged procedure body for a procedure that is listed in the package spec:
PROCEDURE RunReportPreRunCustomCode
(in_report_oid IN NUMBER
,in_pageSize_nr IN INTEGER
,in_parameterList_tt IN parameterKeyValuePair_TT
,inout_reportRun_oid IN OUT NOCOPY NUMBER
,inout_error_yn IN OUT NOCOPY VARCHAR2
,inout_outputOption IN OUT NOCOPY VARCHAR2
,inout_reportOutPut_cl IN OUT NOCOPY NCLOB
IS
BEGIN
NULL; -- Compiler shows this warning for this line: Warning(667,7): PLW-06002: Unreachable code
-- dbms_output.put_line('x');
END;
It gets better! I removed the comment line and the warning stopped showing up. I put the comment line back in, and it hasn't come back (yet). I've seen this before.
Removing the comment in this procedure also caused the same warning for another procedure to go away!
The code in that procedure looked like this:
BEGIN
IF in_some_param IS NULL THEN
NULL;-- Compiler shows this warning for this line: Warning(667,7): PLW-06002: Unreachable code
ELSE
...Does compiling in SQL*Plus also produce the same behaviour? It should, since they both use the same compiler.
I've just tested this in SQL*PLus. After setting the plsql_warnings to "enable:all" to match the default settings in sqldeveloper, the same warning is produced so it is a dbms issue, not sqldeveloper issue.
Edited by: Jim Smith on Oct 11, 2008 4:01 PM -
Does access scope change the way Object oriented code compiles or executes
I have started using Acess Scope (Private/Public/Protected/Friend) in my code and I am wondering if ti changes the way the software is compiled and executed.
I am suffering a 6 minute pre-load startup time and am scrambling to find aything that helps.
Tim L.
iTm - Senior Systems Engineer
uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RTHi Timmar,
I don’t think that the Access Scope is the cause of this long pre-load time. However, you can try to set to public in order to see if that makes any change.
I think this long pre-load time could be related to how many files (VIs and dependencies) are included in your project. Also, if you move the Project folder to a different location (or computer) the next time that you try to open the project it will take a little while to open.
Regards,
Richard. -
Is there such thing as a "compile and execute statement" in Java?
I wanted to know if there's any way to compile and execute a program "within" another program.
Yes, but the classes to do so aren't officially supported by Sun as far as I know.
And you must be able to assume a thing or two about the stuff you compile, such as existing constructors or factory methods etc, otherwise it gets hairy.
Here's some example code (haven't tried it, so excuse any spelling errors etc) to compile the source code in a file called MyClass.java:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
new sun.tools.javac.Main(baos,null).compile("MyClass.java");
String theMsg = baos.toString();
if (theMsg.length() > 0)
// NiftyErrorHandlingHere
}After that, you can load it with a simple ClassLoader.loadClass() call and create instances of it.
It must be compiled with the tools.jar file in the classpath, to find the sun.tools.javac.Main class.
However, for any such dynamically compiled class to be of any use to you, you must be able to assume something about it, such as implementing interfaces or whatever, otherwise it's a kind of pointless exercise.
HTH,
F -
Java run time error while executing JavaFX code
Hi
I copied the code from [http://java.sun.com/javafx/1/tutorials/ui/overview/UIControls.fx|http://java.sun.com/javafx/1/tutorials/ui/overview/UIControls.fx] while
reading in [http://java.sun.com/javafx/1/tutorials/ui/overview/#controls|http://java.sun.com/javafx/1/tutorials/ui/overview/#controls] tutorial and paste it to my
netbeans editor but i got following error.
init:
deps-jar:
compile:
jar:
standard-run:
# An unexpected error has been detected by Java Runtime Environment:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d94513f, pid=5152, tid=5996
# Java VM: Java HotSpot(TM) Client VM (1.6.0_03-b05 mixed mode, sharing)
# Problematic frame:
# V [jvm.dll+0xd513f]
# An error report file with more information is saved as hs_err_pid5152.log
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
BUILD FAILED (total time: 18 seconds)can anyone tell whether its netbeans fault or javaFX. I am using netbeans 6.5.1 on windows vista. I have added following plugin in netbeans for javaFX
*JavaFX Kit
*JavaFX SDK for Windows
is anyone also getting this error for this code and have solution for this.You are correct the crash is causing due to ToggleButton and ProgessBar. the code is correct because i tried it on eclipse 3.4 and it worked fine.This is definitely netbeans error. because its giving error even if u try to execute javafx code with just one ToggleButton or ProgressBar. I tried the following simple code in netbeans 6.5
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.ProgressBar;
var toggle=ToggleButton {
translateX:50
translateY:50
text: "First"
width:100
height:20
var progress= ProgressBar {
progress: bind ProgressBar.computeProgress( 100, 30 )
Stage {
title : "Toggle Button Test"
scene: Scene {
width: 200
height: 200
content: [ toggle
} When i just added toggle button to contents then button showed up in window but on clicking it window disappear and compiler gave crash error on the other hand when i added just progess bar it just throws the error.The same code is running fine on eclipse
Is there any workaround in netbeans for this if its a bug and if not what should i do to correct it. -
Warning(3806,7): PLW-06002: Unreachable code
Why do I got this warning:
Warning(3806,7): PLW-06002: Unreachable code
for this code:
if p_ws = 'D' then
raise_application_error(-20020, 'My Error');
else -- <--Here
return;
end if;
Thank you in advance.
P.S. p_ws is of varchar2 type.user504063 wrote:
Why do I got this warning:
Warning(3806,7): PLW-06002: Unreachable code
for this code:
if p_ws = 'D' then
raise_application_error(-20020, 'My Error');
else -- <--Here
return;
end if;
Thank you in advance.
P.S. p_ws is of varchar2 type.Why return? This really seems to do nothing to me.
Your code is identical to
if p_ws = 'D' then
raise_application_error(-20020, 'My Error');
end if;So the compiler warning might be a good hint. The else part is not needed (although it is reachable...).
Some warnings can be ignored, but in general I would try to look careful and understand what seems to disturb the compiler.
Edited by: Sven W. on Mar 26, 2009 11:45 AM -
Compiling and running jsp-code on the fly.
I am intending to use jsp as a report engine. The 'templates' should be jsp-code stored in the db, loaded and executed as if they where inside a plain jsp-file in the application. I cannot write new files on the file system since this is prohibited on the production env - so I would like to compile and execute the jsp-code directly in memory.
Was hoping this could be done with the jee standard stack.
Does anybode know how to to this, if possible?If you just want to run java applications, you just need the JRE: J2SE 5.0 JRE
If you want to compile java source code, you need the JDK: J2SE 5.0 JDK
It includes also the JRE. Recommended is also the J2SE 5.0 Documentation that contains the javadoc API that describes all the Java classes.
To start develeoping I recommend the Java Tutorial: http://java.sun.com/docs/books/tutorial/ -
Hello
is it possible to execute a .class file which is n an other directory without changing directory ?
E:\FAC\PROJET\Demo>javac HelloWord.java
E:\FAC\PROJET\Demo>java HelloWord
Hello Word
E:\FAC\PROJET\Demo>cd..
E:\FAC\PROJET>java E:\FAC\PROJET\Demo\HelloWord
Exception in thread "main" java.lang.NoClassDefFoundError: E:\FAC\PROJET\Demo\HelloWord
E:\FAC\PROJET>How should I do ?
In fact my problem is that I have made a simple Java editor which can compile en run java code. When I open a java file which is situated somewhere on the drive, and I try to compile it works:
javac /somwhere/on/the/direve/myFile.javaBut it seems it is not possible to execute n this way.
My app is of course using runtime.exec(command); class to run the command.
do you have any ideas ?
Thank you !Try java -classpath %CLASSPATH%;.
HelloWord
For executing the class with the absolute path, use
java -classpath %CLASSPATH%;C:\Foo\Bar HelloWordwhere C:\Foo\Bar contains the class file. :) -
Error when executing Java code, java.lang.NoClassFoundError:
Hi, I am new learner in Java Programming and I am using J2SDK and notepad to write a code. I don't have problem in compiling using javac filename, however I received an error when executing using java filename.
The error message I got is Exception in thread "main" java.lang.NoClassDefFoundError: Hello/jawa.
I have verified this simple code - Hello has no issue but somehow it does not run. I even try to compile and execute in other computer also the similiar error returned.
My Client Platform is Windows XP Professional.
I would appreciate any expert can help to suggest me the knowledge/solution to fix this kind of error. Thanks
JackieIt looks like you entered the command "java Hello.java" or "java Hello/java" (I assumed 'jawa' was a typo.)
You should have entered "java Hello" if your class name is Hello. I am guessing that Hello.java is probably the source code file name. The argument to the java command is the fully qualified class name. "java Hello.java" tells the java command to look for a class named java that is in the Hello package. -
Convert strings to executable java code
Hey,
I'm not sure how easy or hard this is to accomplish, but I am looking for a way to take a string from a JTextField and use it as a control structure for an IF block.
For example, the user inputs 'keyword=="test" || keyword=="test2"' I want to use it in an if block to control it.
Is there a way to do this? I realize the java file is already compiled in a class, so the string would probably be incapable of doing such a thing.
Any thoughts would be appreciated!Basically this is impossible, because Java is a compiled language, but there are ways around it.
Actually the ways are all basically one way: use an interpreted language. You can embed one into Java. You can write your own, new language (it could be a small simple mini-language, for example one that only evaluates boolean expressions; this is easier than it sounds), or you can use one that already exists.
There already is an interpreted language for Java. It's called BeanShell. Also I'm told that someone has written a javascript interpreter for Java, but I don't know the details.
I'd suggest Googling for BeanShell. It sounds like the quickest, easiest solution.
But be careful: letting users execute arbitrary code can be a huge security hole. -
Executing Simulink Code on cRIO
Hi everyone,
I am wondering if anyone has a Mathworks Simulink model running on an RT target such as cRIO.
In other projects I've done this on the past using LabVIEW 2010 SP1 and Simulation Interface Toolkit (SIT). You would compile a Simulink model as a DLL, OUT or RTDLL, and used it on a timed loop with SIT's VIs.
What I am reading for LabVIEW 2014 talks about Model Interface Toolkit, but it always refers to running the compiled model on a Host PC.
Does anyone know if it is possible to run DLL compiled with MIT on an RT target????
Regards!
g_l_u_p
Solved!
Go to Solution.A DLL is a Windows executable format. As such it only ever can run on Pharlap based RT targets. VxWorks based ones use the special .out format, while the new Linux RT are using ELF shared libraries, compiled either for the ARM (cRIO 906x and myRIO) or x64 (cRIO 903x) architecture. So unless your Simulink code can be compiled to either of these two shared library formats, you can not execute the code on any of the non Pharlap based targets.
Even the Pharlap ones pose some serious challenges. For one the Pharlap ETS OS is not a fully implemented Win32 API but a subset of this. DLLs that are compiled to run on an NT4 or 2000 system have a good chance to run on Pharlap. DLLs for newer Windows variants are likely to make use of either Win32 APIs that do not exist in Pharlap ETS or of Visual C runtime versions that are not available for the Pharlap OS. The Visual C 6 runtime was directly implemented in the Win32 API and basically didn't require any extra install if you were not running on Win95. NI ported the Visual C 7.1 and Visual C 9.0 runtime to their Pharlap targets but newer C runtimes than that are simply not supported. And Visual C DLLs and executables require different runtimes for each Visual C version. So unless your DLL is compiled with Visual C 6, 2003 (MSVC runtime 7,1) or 2008 (MSVC runtime 9.0) the DLL will likely not be compatible with the Pharlap RT system either.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Batch file to execute java code
Hi,
I need to write a batch file to execute a sequence of java applications.
The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operationdexterity wrote:
Hi,
I need to write a batch file to execute a sequence of java applications.
The problem i face is in addition to the usual libraries I am also using certain jar files i downloaded like the mail interface etc.
When i just compile a java code using a simple batch file giving the path of the compiler and the java code, it fails citing not knowing the location if the packages.
could anyone please let me know what i need to do. Is there like a skeleton that i might find somewhere for this operationSet the classpath correctly at runtime.
Why do you need the location of your compiler? Are you compiling or running? If you are compiling go look at Ant. -
Hi,
I am getting error PLW-06002 unreachable code at quite a few places . I guess my loops have some problem
but I am not able to find out reason for that. I apologize for inconveinence caused by unformatted code.
I have tried to format it, please help me to fix this mess.
create or replace procedure wip_case2_proc (p_packing_id IN packing.packing_id%TYPE,
p_new_qty IN NUMBER,
o_return_msg OUT VARCHAR2 )
is
v_tran VARCHAR2(1);
v_new_qty NUMBER;
v_new_line_status VARCHAR2(5);
v_err_msg VARCHAR2(100);
vo_order_number orders.order_number%type;
v_line_status ordered_items.status%TYPE;
ordadjrec orders%ROWTYPE;
itemrec ordered_items%ROWTYPE;
v_msg VARCHAR2(200);
v_client VARCHAR2(20);
v_order_number VARCHAR2(20);
ordrec orders%ROWTYPE;
ord orders.order_number%TYPE;
oirec ordered_items%ROWTYPE;
CURSOR c_packing IS
SELECT p.client,
p.order_number
FROM packing p,
packing_attributes pa,
orders o,
business_partner bp
WHERE p.packing_id = p_packing_id
AND p.packing_id = pa.packing_id
AND p.client = o.client
AND p.order_number = o.order_number
AND o.client = bp.client
AND o.business_partner = bp.business_partner;
CURSOR c_adj_item (p_order_number VARCHAR2, p_client VARCHAR2) IS
SELECT oi.*
FROM ordered_items oi, packing_details pd
WHERE oi.order_number = p_order_number
AND pd.packing_id = p_packing_id
AND oi.client = p_client
AND oi.ordered_item_id = pd.ordered_item_id
AND oi.stock_number = pd.stock_number;
CURSOR c_adj_order (p_order_number VARCHAR2, p_client VARCHAR2) IS
SELECT *
FROM orders
WHERE order_number = p_order_number
AND client = p_client;
CURSOR c_lines (p_order_number VARCHAR2, p_client VARCHAR2) IS
SELECT oi.*
FROM ordered_items oi, packing_details pd
WHERE oi.order_number = p_order_number
AND pd.packing_id = p_packing_id
AND oi.client = p_client
AND status = 'B'
AND oi.ordered_item_id = pd.ordered_item_id
AND oi.stock_number = pd.stock_number ;
CURSOR c_back_order(p_order_number VARCHAR2, p_client VARCHAR2) IS
SELECT o.*
FROM packing p,
packing_attributes pa,
orders o
WHERE p.packing_id = p_packing_id
AND p.packing_id = pa.packing_id
AND p.client = o.client
AND p.order_number = o.order_number
AND o.order_number = p_order_number;
-----------------------------MAIN---------------------------------
BEGIN
DBMS_OUTPUT.put_line ('adjust c_adj_item packing');
---adjust
v_tran := 'U';
v_line_status := 'S';
v_new_qty := p_new_qty;
OPEN c_packing;
Loop
Fetch c_packing into v_client,v_order_number;
OPEN c_adj_item (v_order_number, v_client);
LOOP
FETCH c_adj_item INTO itemrec;
DBMS_OUTPUT.put_line ('adjust c_adj_order packing');
OPEN c_adj_order (v_order_number, v_client);
FETCH c_adj_order INTO ordadjrec;
cmn_backorder_pkg.adjust_order_items(v_tran,
ordadjrec,
itemrec,
v_new_qty,
v_line_status, v_msg);
CLOSE c_adj_order;
END LOOP;
close c_adj_item;
DBMS_OUTPUT.put_line ('open c_back_order');
OPEN c_back_order(v_order_number, v_client);
LOOP
FETCH c_back_order INTO ordrec;
EXIT WHEN c_back_order%NOTFOUND;
OPEN c_lines (v_order_number, v_client);
LOOP
FETCH c_lines INTO oirec;
EXIT WHEN c_lines%NOTFOUND;
wip_pkg.create_bo_item (oirec, v_order_number);
END LOOP;
CLOSE c_lines;
wip_pkg.create_new_backorder (ordrec);
END LOOP;
CLOSE c_back_order;
END LOOP;
CLOSE c_packing;
o_return_msg := '0';
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
o_return_msg := 'WIP reversal error: ' || SQLERRM;
END wip_case2_proc;Edited by: sandy162 on May 1, 2009 1:44 PMHi,
sandy162 wrote:
Sorry for inconveience, I have formatted code..That's a step in the right direction.
Now make the formatting reflect what you're doing: in particular, where the loops begin and end.
That is, you posted
OPEN c_adj_item (v_order_number, v_client);
LOOP
FETCH c_adj_item INTO itemrec;
DBMS_OUTPUT.put_line ('adjust c_adj_order packing');
that makles it look like the call to put_line is outside of the loop.
I would suggest something like:
OPEN c_adj_item (v_order_number, v_client);
LOOP
FETCH c_adj_item INTO itemrec;
DBMS_OUTPUT.put_line ('adjust c_adj_order packing');Don't forget to indicate the 2 or 3 lines that you added since the last time the code ran without erros, and post the complete error message.
Maybe you are looking for
-
How to change the plant manually in the order
Hi All, I have created a debit memo for two items in va01 with ref to the service order,for 1 item wrong plant has been triggered.We have created the billing document for two different item,now i have to change the plant of 1 item,so i have de
-
How do I authorise a new computer to download Adobe Mobile Reader
I jhave been using Adobe Mobile Reader to download eBooks to my computer for further download to my Sony eBook Reader.I have now bought a new Toshiba laptop. How do I authorise my new laptop so tthat I can continue to download Ebooks to it. Any h
-
Connecting WRT300N to internet using 802.11x
My service provider requires 802.11x authentication to connect to Internet. Is there any way to get my WRT300N to act as a 802.11x client on it's internet connection?
-
BI 7.0 Master Data Migration
Hi Gurus, I have seen few threads for BI 7.0 Datasource Migration for transaction data but is it necessary to migrate even master data datasources (Attr and text, I understand that Hier DS cannot be migrated). Will there be any impact if we do not mi
-
How to associate a default catalog to CatalogTools in 10.2
Hi Guys, Can you throw your ideas. how to associate a default catalog to CatalogTools in 10.2. can i associate catalog to user through scenario in ATG10.2 ? Thank you.