473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to use assert

I would like to use the assert keyword, but my compiler doesn't seem to
recognize it. It's also not in the api (only the AssertionError is).

What am I missing? I'm using 1.4.1_05 on windows.

Thanks
Jul 17 '05 #1
3 4141
"Eric" <er************@verizon.net> wrote in message news:<UB*****************@nwrdny03.gnilink.net>...
I would like to use the assert keyword, but my compiler doesn't seem to
recognize it. It's also not in the api (only the AssertionError is).

What am I missing? I'm using 1.4.1_05 on windows.

Thanks


From Sun's documentation
(http://java.sun.com/j2se/1.4.1/docs/...ml#compiling):

"Compiling Files That Use Assertions
In order for the javac compiler to accept code containing assertions,
you must use the -source 1.4 command-line option as in this example:

javac -source 1.4 MyClass.java
This flag is necessary so as not to cause source compatibility
problems. "

mypetrock
Jul 17 '05 #2

"Doyle" <my*******@yahoo.com> wrote in message
news:73**************************@posting.google.c om...
| "Eric" <er************@verizon.net> wrote in message
news:<UB*****************@nwrdny03.gnilink.net>...
| > I would like to use the assert keyword, but my compiler doesn't seem to
| > recognize it. It's also not in the api (only the AssertionError is).
| >
| > What am I missing? I'm using 1.4.1_05 on windows.
| >
| > Thanks
|
| From Sun's documentation
| (http://java.sun.com/j2se/1.4.1/docs/...ml#compiling):
|
| "Compiling Files That Use Assertions
| In order for the javac compiler to accept code containing assertions,
| you must use the -source 1.4 command-line option as in this example:
|
| javac -source 1.4 MyClass.java
| This flag is necessary so as not to cause source compatibility
| problems. "
|
| mypetrock

You also need to enable assertions when you start up the JVM with the -ea
flag
'java -ea MyClass'
--
-P
Jul 17 '05 #3
Here are some quick notes on usign assertions :
http://www.javapractices.com/TableOf...cjp#Assertions

Eric wrote:
I would like to use the assert keyword, but my compiler doesn't seem to
recognize it. It's also not in the api (only the AssertionError is).

What am I missing? I'm using 1.4.1_05 on windows.

Thanks


Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
3
by: Thomas Guettler | last post by:
Hi, Python 2.3.3 (#1, Feb 5 2005, 16:22:10) on linux2 >>> assert 0, "foo" Traceback (most recent call last): File "<stdin>", line 1, in ? AssertionError: foo >>> assert(0, "foo") >>>
27
by: Daniel Vallstrom | last post by:
I'm having problems with inconsistent floating point behavior resulting in e.g. assert( x > 0.0 && putchar('\n') && x == 0.0 ); holding. (Actually, my problem is the dual one where I get...
5
by: Alex Vinokur | last post by:
Here are two programs. --- foo1.c --- #include <assert.h> #define FOO 10 int main() { assert (15 < FOO); return 0; }
47
by: Rob Thorpe | last post by:
In general, is it considered bad practice to use asserts in production code? What about writing a macro that does the same as assert but continues to work regardless of the state of NDEBUG? I...
28
by: lovecreatesbeauty | last post by:
Besides printing out for example " a.out: p113.c:8: main: Assertion `0' failed. Aborted " and a switch option NDEBUG, what other benefits does assert() provide in any scope of designing,...
13
by: priyanka | last post by:
Hi there, Can anyone show me how the assert() function works ? I need to develop my own assert() function instead of using the one defined in the assert.h file. It would be great if anyone could...
12
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I saw a couple of form of assert in code on Windows, 1. ASSERT; 2. assert; 3. _ASSERT; 4. _assert.
30
by: Tomás Ó hÉilidhe | last post by:
In C89, do we have to pass an int as an argument to assert? I've got code at the moment that does an assertion on pointer, e.g.: assert(p); , but I'm wondering if I should change that to: ...
9
by: pereges | last post by:
Ok, so once I'm done debugging my code(split across multiple modules) using the assert macro, I would want to switch off all the assert macros ued in the program. Does this mean I have to include:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.