Be careful when using RFT reflection feature

If you met below error when try to start RFT script using CLI,

Unhandled exception in rational_ft: com.rational.test.ft.util.ConfigReadExceptio
n: CRFCN0169E: Error loading configuration file [CRFCN0123E: Exception parsing f
ile: C:\Program Files\IBM\SDP\FunctionalTester\bin\rational_ft.rftcust]

Check if you have ever use reflection in any plain java class, if yes, then change the class to RFT script.


“Finally” get understood

I have been always use finally to clean up the mess to make my method end up gracefully, and it looks like the the finally code block is the last stop of the code flow. But wait, have you ever think about why IDE are not force you to write a return statement? If it is really the last stop, then you need to add return statement for a method requires a output parameter. It looks weird, but fortunately I could look for answer in my Eclipse:

public int f1(){
try{
x = 1;
return x;
}finally{
x = 2;
}
}

And this method print 1. So it looks the finally is NOT the last stop, otherwise we should saw 2. What’s wrong? Then I expended the method a bit:

public class TestTryCatchFinally {
static int x = 0;

public static void main(String[] args){
System.out.println(f1() );
System.out.println(f2() );
}

public static int f1(){
try{
x = 1;
return x;
}finally{
x = 2;
}
}

public static int f2(){
return x;
}
}

We got

1

2

printed this time, it proof the finally block is really the last one get executed, even after return statement.


StackTrace is more than debuging

I’ve never think about what else StackTrace could do other than debuging, util I read this post.

public static String getCallingMethodInfo() {
final Throwable fakeException = new Throwable();
final StackTraceElement[] stackTrace = fakeException.getStackTrace();
if(stackTrace != null && stackTrace.length >= 2) {
StackTraceElement s = stackTrace[2];
if(s != null) {
return s.getClassName() + “.(” + s.getMethodName() +”):["+ s.getLineNumber() + "] -:”; }
} return null;
}


Charactoristic of a Chain Code Matrix

1. Zero (0) could only exist in the beginning of of a line.

2. The sum of the line is number of the columns of the original matrix, that means the sum of different lines of a Chain Code Matrix are the same.


Java class with compilation problem

I have met a similar problem as mentioned here,

I have a project that generate some java code and I will need these java class in another project. The generated code has some error because it need a dependant library, but Eclipse still generate the class file for them, even it has unresolved class reference. I actually noticed the error I still package them into a jar and import it the other project, because I thought the if I could import the dependant library in that project also, I’ll be safe. But I was wrong, the “Unresolved compilation problem” still occurred even I included the dependant library.

The solution is to include the dependant library into the original project that generate the code, make sure there is no error in the generated code and then included into the other project.


JR photo


Create new class in Eclipse

Ever want to create a new class of which content from clip board? Don’t bother to create a new empty class and copy the code. Just click on the package and press Ctrl+V. Bingo!


Follow

Get every new post delivered to your Inbox.