Hi,
I am trying to understand some java code which for some reason appears to execute its return type class (the SQLExecutionInfo class) and nothing else within the method. Perhaps this is simply how the java works (i.e regardless of whether of what is within the method body the type of class being returned is first executed ??)
The method begins thus:
protected Query.SQLExecutionInfo compileSingleQDB(StatementExpression statement, boolean keyNeeded) throws StatementException, XMLDBCException {
//body of method
System.out.println("body of method");
}
/*****THE REFERENCED SQLExecutionInfo class is a subclassed within Query.java***********/
public static class SQLExecutionInfo {
public SqlExpression sql = null;
public StatementInfo sInfo = null;
public Mapper mapper = null;
public List childrenQueries = null;
public int[] idPosition = null;
public int idCount = -1;
public SQLExecutionInfo() {
}
public SQLExecutionInfo(SqlExpression sql, Mapper mapper) {
System.out.println("POINT ALPHA2:"+ sql);
this.sql = sql;
this.mapper = mapper;
}
For some reason nothing in the compileSingleQDB method (i.e the body) is executed however the class SQLExecutionInfo is called and System.out.println("POINT ALPHA2:"+ sql) is invoked.
Could anyone please explain to me why this is ?
Thanks, Pablo
Please let me provide more info:
This one has me puzzled,
The code execution all begins here:
System.out.println("POINT SQL:"+jdbcExecInfo.sql); // Returns null at this stage
try {
System.out.println("POINT A");
jdbcExecInfo = compileSingleQDB(((Variable) Qdb.get(0)).getExpression(), false);
System.out.println("POINT B");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("POINT SQL:"+jdbcExecInfo.sql); // Somehow now has a value ????
Somehow it still reaches POINT B and even if I put: Thread.dumpStack();
and new Error().printStackTrace();
within the compileSingleQDB method nothing comes up.
Also even if I rip out the internals of the compileSingleQDB method and replace it with:
protected Query.SQLExecutionInfo compileSingleQDB(StatementExpression statement, boolean keyNeeded) throws XQueryException, XMLDBCException {
return null;
}
the string jdbcExecInfo.sql still somehow gets a value