@@ -0,0 +1,2775 @@
+import java.io.File;%0Aimport java.io.FileWriter;%0Aimport org.apache.bcel.Repository;%0Aimport org.apache.bcel.classfile.*;%0Aimport org.json.simple.JSONObject;%0Aimport org.json.simple.JSONArray;%0A%0Aclass ParseExamples %7B%0A    public static void main(String%5B%5D args) throws java.lang.Exception %7B%0A        String%5B%5D classNames = RunExamples.classNames();%0A%0A        // e.g. com.opengamma.Class used in com.opengamma.example.ExampleClass:MethodName%0A        JSONObject classesUsed = new JSONObject();%0A%0A        for (int k = 0; k %3C classNames.length; k++) %7B%0A            String className = classNames%5Bk%5D;%0A            JavaClass clazz = Repository.lookupClass(className);%0A            ConstantPool pool = clazz.getConstantPool();%0A%0A            // Check each method in this class to see which OpenGamma classes it uses%0A            Method%5B%5D methods = clazz.getMethods(); for (int i = 0; i %3C methods.length; i++) %7B%0A                Method method = methods%5Bi%5D;%0A                Code code = method.getCode();%0A%0A                // code.toString calls Utilities.codeToString which does lots%0A                // of useful parsing but then stores everything in a String%0A                // instead of a more accessible format, so we need to parse the string%0A                String%5B%5D codeLines = code.toString().split(%22%5Cn%22);%0A                for (int m = 0; m %3C codeLines.length; m++) %7B%0A                    String line = codeLines%5Bm%5D;%0A                    int x = line.indexOf(%22invokespecial%22);%0A                    int y = line.indexOf(%22.%3Cinit%3E%22);%0A                    if (x %3E 0 && y %3E 0) %7B%0A                        String usedClassName = line.substring(x+13, y).trim();%0A                        if (usedClassName.startsWith(%22com.opengamma%22)) %7B%0A                            // This is one we are interested in!%0A                            JSONArray methodsUsedIn;%0A%0A                            if (classesUsed.containsKey(usedClassName)) %7B%0A                                // Get existing array...%0A                                methodsUsedIn = (JSONArray)classesUsed.get(usedClassName);%0A                            %7D else %7B%0A                                // Init new array...%0A                                methodsUsedIn = new JSONArray();%0A                            %7D%0A                            String methodKey = className + %22:%22 + method.getName();%0A                            methodsUsedIn.add(methodKey);%0A                            classesUsed.put(usedClassName, methodsUsedIn);%0A                        %7D%0A                    %7D%0A                %7D%0A%0A                File f;%0A                FileWriter file;%0A%0A                f = new File(%22../dexy--depends.json%22);%0A                file = new FileWriter(f);%0A                classesUsed.writeJSONString(file);%0A                file.close();%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add script to detect which classes are being used (i.e. a new instance being creaetd) in examples.