[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-jel] Null return from String method

From: Mark Taylor
Subject: [Help-jel] Null return from String method
Date: Tue, 18 Jun 2019 15:25:52 +0000

Dear Konstantin,

there seems to be something surprising going on if I return null
from a String-typed method during JEL evaluation.  Here is a test

    import gnu.jel.CompiledExpression;
    import gnu.jel.Evaluator;
    import gnu.jel.Library;

    public class STest {
        public static void main( String[] args ) throws Throwable {
            Library lib = new Library( new Class[] { STest.ALib.class },
                                       null, null, null, null );
            for ( int i = 0; i < 4; i++ ) {
                String sexpr = "txt(" + i + ")";
                CompiledExpression compex = Evaluator.compile( sexpr, lib );
                System.out.println( sexpr + "=" + compex.evaluate( null ) );

        public static class ALib {
            public static String txt( int i ) {
                return i == 2 ? null : Integer.toString(i);

If I run it with jel_g.jar from
I see this on stdout/stderr:

    [DEBUG] typeIDObject(what)=8
    [DEBUG] instead.resID=11
    [DEBUG] what=null

If I run it with jel.jar, I see this:

    Exception in thread "main" java.lang.NullPointerException
            at gnu.jel.ClassFile.getUTFIndex(Unknown Source)
            at gnu.jel.ClassFile.getIndex(Unknown Source)
            at gnu.jel.ClassFile.codeLDC(Unknown Source)
            at gnu.jel.OPload.compile(Unknown Source)
            at gnu.jel.OPunary.compile(Unknown Source)
            at gnu.jel.Evaluator.getImage(Unknown Source)
            at gnu.jel.Evaluator.compileBits(Unknown Source)
            at gnu.jel.Evaluator.compile(Unknown Source)
            at gnu.jel.Evaluator.compile(Unknown Source)
            at STest.main(

This doesn't seem to be a new problem at JEL 2.1.1, all the versions
I have lying around seem to do the same thing.  Given which, I am
extremely surprised that I haven't come across this before in
more than 15 years of heavy JEL use, but I suppose most of my
functions are numeric and not strings.

Can you comment?

Many thanks,


Mark Taylor   Astronomical Programmer   Physics, Bristol University, UK
address@hidden +44-117-9288776

reply via email to

[Prev in Thread] Current Thread [Next in Thread]