Freud 1.0 is out

Yesterday I bumped up the version of Freud from 0.9 to 1.0.

Apart from finally getting round to write some wiki entries on how to start using Freud, the main addition is the support for analysis of Java class files.
Freud can now iterate over class files and parse them into a ClassFile object.
This allows assertions to inspect the constant pool, the fields and methods inside the class.
Inside every method, we can now look into the JVM instruction set, the local variables etc. and assert things like:
There should be no call to BigDecimal.equals(Object) method (i.e we don’t want to use equals – good in contexts where all we care about is the equality of the numeric value – not true object equality).



public static FreudAnalyser 

doNotUseBigDecimalEquals(final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).
within(iterator).
assertThat(no(
hasMethodInvocation(BigDecimal.class, "equals", Object.class)));
}

or

The code should not throw any exceptions


public static FreudAnalyser 

doNotThrowAnyExceptions(final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).within(iterator).
assertThat(no(containsInstructions(Opcode.ATHROW)));
}

also – any method named “criticalPath” must not have any branch logic


  public static FreudAnalyser 

specificMethodsShouldNotHaveBranchLogic(
final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).within(iterator).
assertThat(no(methodName().matches("criticalPath")).
or(no(containsInstructions(Opcode.IFEQ,
Opcode.IFLT,
Opcode.IFLE,
Opcode.IFNE,
Opcode.IFGT,
Opcode.IFGE,
Opcode.IFNULL,
Opcode.IFNONNULL,
Opcode.IF_ICMPEQ,
Opcode.IF_ICMPGE,
Opcode.IF_ICMPGT,
Opcode.IF_ICMPLE,
Opcode.IF_ICMPLT,
Opcode.IF_ICMPNE,
Opcode.IF_ACMPEQ,
Opcode.IF_ACMPNE,
Opcode.TABLESWITCH,
Opcode.LOOKUPSWITCH,
Opcode.GOTO,
Opcode.GOTO_W,
Opcode.JSR,
Opcode.JSR_W))));
}


etc.

This joins the list of other currently supported content types in Freud:


Text

(For asserting things like – number of lines, line length, regex queries etc.)

Java Source

(Tests may include code block source size or existence of compile time annotation etc.).

Java Class
(Analysing declared methods signatures, fields, access modifiers etc.)
Properties
(Existence of properties, inspecting values using regex etc.)
CSS


(Analysing css rule declarations, ordering, patterns and conventions etc.)
Spring config.


(Bean construction/naming conventions, and also coupled with java class assertions – existence of specific annotations for specific spring beans etc.)
What’s next?
Adding more and more custom assertions to the growing DSLs inside Freud.
So far I’ve only added assertions as I needed them.
If anyone needs an assertion that does not exist – That shouldn’t stop you.
An assertion is simply a hamcrest matcher – implement it and if its generic enough to be reused, please let me know about it so I can add it to the right DSL.

Any opinions, news, research, analyses, prices or other information ("information") contained on this Blog, constitutes marketing communication and it has not been prepared in accordance with legal requirements designed to promote the independence of investment research. Further, the information contained within this Blog does not contain (and should not be construed as containing) investment advice or an investment recommendation, or an offer of, or solicitation for, a transaction in any financial instrument. LMAX Group has not verified the accuracy or basis-in-fact of any claim or statement made by any third parties as comments for every Blog entry.

LMAX Group will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information. No representation or warranty is given as to the accuracy or completeness of the above information. While the produced information was obtained from sources deemed to be reliable, LMAX Group does not provide any guarantees about the reliability of such sources. Consequently any person acting on it does so entirely at his or her own risk. It is not a place to slander, use unacceptable language or to promote LMAX Group or any other FX and CFD provider and any such postings, excessive or unjust comments and attacks will not be allowed and will be removed from the site immediately.