stg-tud / MUDetect

Mozilla Public License 2.0
24 stars 8 forks source link

ImportException when Writing/Reading Java files with special characters #17

Open SNielebock opened 5 years ago

SNielebock commented 5 years ago

When the AUGWriter is writing a source file with an escaped double quote (\") in it, it exports this just as a usual double quote (") in the respected dot-file. However, this might introduce invalid dot syntax and therefore the AUGReader cannot read this and throws an ImportException. This seems to be a rare event, however, this could happen quite often when working with regular expressions in the code.

Here is a minimal example of this behavior. The AUGWriter transforms this source code

public class Test{
    public static void main(String... args) {
        System.out.println("\"[]");
    }
}

into this (invalid) dot graph code:

graph G {
  1 [ label="L" t="String" v=""[]" ];
  2 [ label="MC" s="println()" t="PrintStream" l="6" ];
  3 [ label="CN" t="PrintStream" v="null" n="System.out" ];
  1 -- 2 [ label="P" ];
  3 -- 2 [ label="R" ];
}

According to the dot-language, the AUGWriter could simply escape the double quote in the dot code. At least for this example, then the import works properly.

BTW: This could be another API misuse in the MUBench dataset? ;)

salsolatragus commented 5 years ago

Thanks for reporting this and for figuring out the issue plus coming up with a minimal example to demonstrate it! I would have expected jGraphT to handle escaping, but apparently it doesn't. I'll have a look whether this is actually expected behaviour of their API.

Not sure whether this is necessarily a misuse in our sense. But I'll keep in mind adding it, should it turn out to be one ;)