Java gson fromJson half the time showing SignatureParser.class source not found error

86 views Asked by At

And the curious thing is that the other half of thetime it actually works... I simply don't get why this is happening.

For some more context, what I'm trying to do is to instanciate an objecto of the class Indexer defined as follows:

public class Indexer {

private String name;
private List<String> allTerms = new ArrayList<String>();
private List<String> filePaths = new ArrayList<String>();
private List<double[]> fileVectors = new ArrayList<double[]>();
/* and the propper setters and getters*/

And here is were the instance is being loaded from a .json file.

public Indexer loadIndex(String indexPath) {
    try {
        String jsonString = new FatherFileReader().getFileContent(indexPath);
        Gson gson = new GsonBuilder().create();
        JsonElement root = new JsonParser().parse(jsonString);
        Indexer indexer = gson.fromJson(root, Indexer.class);
        System.out.println(indexer.getName());
        return indexer;

    } catch(Exception e){
        e.printStackTrace();
    }
    return null;

When I execute it, it does print the atribute name from the indexer object, but the second time I try, a tab right beside the console appears with the name SignatureParser.class appears with the following message. And the third time I try... it works again!! And so on... Also, it doesn't fall on the catch block, so it doesn't print the StackTrace and the program just halts and the tab pops up.

Class File Editor Source not found The source attachment does not contain the source for the file SignaturesParser.class. You can change the source attachment by clicking the Change Attached Source below.

I don't know what's going on... I would be really thankfull for some help.


EDIT

I already got it to work consistently by running it as a Java aplication istead of running it with the eclipse debugger... I still am curious to know what's going on. But for now i', going to test with the java aplication runner.

0

There are 0 answers