High global cost is assigned to switch statements on enums

0 views
Skip to first unread message

aeagl...@gmail.com

unread,
Mar 25, 2009, 8:18:52 PM3/25/09
to shyams...@gmail.com, testability-...@googlegroups.com
Reviewers: shyamseshadri,

Description:
When a Java 1.5 enhanced switch statement is used on an enum, a
synthetic class is created as an anonymous inner class of the class
where the switch statement appears. That synthetic class stores a statuc
array of the values of the enum, which is named
$SwitchMap$com$google$AnEnum.

What's more, the number of assignments into that array is pyramid(N),
where N is the number of case clauses in the switch. Ie. for 14 case
clauses, we got a global cost of 105.

We don't want to record the assignments into this JVM-internal array.

Please review this at http://codereview.appspot.com/28107

Affected files:

core/src/main/java/com/google/test/metric/method/op/turing/ArrayAssignment.java
core/src/test/java/com/google/test/metric/InnerEnumHolder.java
core/src/test/java/com/google/test/metric/MetricComputerTest.java


Reply all
Reply to author
Forward
0 new messages