Ah, OK. Well, the origin of this behavior is that this is how the read-
eval-print loop worked in CLIPS:
CLIPS> new java.net.URL foo://bar/
new
For many other Lisp-like languages, this would be an error, but in
CLIPS and Jess, a bare symbol is just a symbol, not a variable, and so
it evaluates OK. Note that the following is an error (and throws an
exception from eval):
Jess> ?new java.net.URL foo://bar/
Jess reported an error in routine Context.getVariable.
Message: No such variable new.
Program text: ?new at line 1.
On Jan 13, 2011, at 9:00 AM, Gelder, Kero van wrote:
Hi all,
We found a test program that indicates that Jess should (re)raise
exceptions from Java to Java.
I typed in the code below, and of course it confirmed my suspicions
that no exception was raised.
We then tried upgrading Jess (from 7.0p1 to 7.1p2), but no change.
That surprised us, so we looked a bit better; can you spot the
mistake in the program below?
Are you sure you DON'T want a JessException, or *any* exception for
this mistake? (i.e. should I file a bug report or feature request?)
Knowing it worked, we knew better where to look and found the place
where the Exception was caught in our code, rather than our framework.
Found it; original question answered.
Bye,
Kero.
import jess.*;
public class TryIt {
public static void main(String arg[]) {
try {
Rete r = new Rete();
r.eval("new java.net.URL foo://bar/");
} catch (JessException e) {
e.printStackTrace();
} catch (Throwable e) {
e.printStackTrace();
}
}
}
__
Kero van Gelder
Software Engineer
Systems Creation
MiPlaza
Philips Research Europe
High Tech Campus 34.6.12 (WY61)
5656 AE Eindhoven
Tel: +31-40-27.47905
E-mail: kero.van.gel...@philips.com
http://www.miplaza.com/
________________________________________
From: owner-jess-us...@sandia.gov [owner-jess-us...@sandia.gov] On
Behalf Of Gelder, Kero van [kero.van.gel...@philips.com]
Sent: Thursday, January 13, 2011 13:13
To: jess-users@sandia.gov
Subject: JESS: Catching a java exception via Jess in Java
Hello!
We are writing unit tests around or software with JUnit and JMock.
When we run certain tests, Jess will call Java methods.
In the unit tests, JMock provides stubs for these methods.
With the expectations set, these method calls may raise an exception.
Jess catches this exception and prints it.
Thus, JUnit does not see the exception.
So when JMock flags a failure, our tests still pass.
A similar thing will happen in the deployed system, of course.
Is it possible to let Jess re-throw the exception?
We tried to find a flag to set on Jess, but could not find any.
We know that try/catch in Jess can install a handler, but we do not
know how to wrap such try/catch when we call Rete.run() from Java.
Other suggestions?
Bye,
Kero.
__
Kero van Gelder
Software Engineer
Systems Creation
MiPlaza
Philips Research Europe
High Tech Campus 34.6.12 (WY61)
5656 AE Eindhoven
Tel: +31-40-27.47905
E-mail: kero.van.gel...@philips.com
http://www.miplaza.com/
The information contained in this message may be confidential and
legally protected under applicable law. The message is intended
solely for the addressee(s). If you are not the intended recipient,
you are hereby notified that any use, forwarding, dissemination, or
reproduction of this message is strictly prohibited and may be
unlawful. If you are not the intended recipient, please contact the
sender by return e-mail and destroy all copies of the original
message.
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov
.
--------------------------------------------------------------------
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users
y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov
.
--------------------------------------------------------------------
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012 ejfr...@sandia.gov
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------