public File getUniqueFilenameForClass(String className) throws IOException {
        //class names should be passed in the normal dalvik style, with a leading L, a trailing ;, and using
        //'/' as a separator.
        if (className.charAt(0) != 'L' || className.charAt(className.length()-1) != ';') {
            throw new RuntimeException("Not a valid dalvik class name");
        }

        int packageElementCount = 1;
        for (int i=1; i<className.length()-1; i++) {
            if (className.charAt(i) == '/') {
                packageElementCount++;
            }
        }

        String[] packageElements = new String[packageElementCount];
        int elementIndex = 0;
        int elementStart = 1;
        for (int i=1; i<className.length()-1; i++) {
            if (className.charAt(i) == '/') {
                //if the first char after the initial L is a '/', or if there are
                //two consecutive '/'
                if (i-elementStart==0) {
                    throw new RuntimeException("Not a valid dalvik class name");
                }

                packageElements[elementIndex++] = className.substring(elementStart, i);
                elementStart = ++i;
            }
        }

        //at this point, we have added all the package elements to packageElements, but still need to add
        //the final class name. elementStart should point to the beginning of the class name

        //this will be true if the class ends in a '/', i.e. Lsome/package/className/;
        if (elementStart >= className.length()-1) {
            throw new RuntimeException("Not a valid dalvik class name");
        }

        packageElements[elementIndex] = className.substring(elementStart, className.length()-1);

        return addUniqueChild(top, packageElements, 0);
    }
@Test
    public void testCaseInsensitiveFilesystem() throws IOException {
        File tempDir = Files.createTempDir().getCanonicalFile();
        ClassFileNameHandler handler = new ClassFileNameHandler(tempDir, ".smali", false, false);

        File file = handler.getUniqueFilenameForClass("La/b/c;");
        checkFilename(tempDir, file, "a", "b", "c.smali");

        file = handler.getUniqueFilenameForClass("La/b/C;");
        checkFilename(tempDir, file, "a", "b", "C.1.smali");

        file = handler.getUniqueFilenameForClass("La/B/c;");
        checkFilename(tempDir, file, "a", "B.1", "c.smali");
    }