Getting error on parsring if Genrics are used in code

56 views
Skip to first unread message

sumitg...@gmail.com

unread,
Feb 20, 2014, 11:46:29 AM2/20/14
to javap...@googlegroups.com
Code i am trying to parse has a map declaration Map<String, String> dataMap = new HashMap<>(); when i try to pares this using javaparser , it gives error as below
Exception in thread "main" japa.parser.ParseException: Encountered " "<" "< "" at line 15, column 58.
Was expecting one of:
    "(" ...
    "(" ...

does javaparser supports generic declaration ?

Julio Gesser

unread,
Feb 20, 2014, 1:09:31 PM2/20/14
to javap...@googlegroups.com
This is happening because the JaraParser is not compatible with Java 7. You are using the diamond operator available only in Java 7, and the JavaParser is compliant only with Java 6.
If you change your declaration to
Map<String, String> dataMap = new HashMap<String, String>();
It will work.

Atenciosamente,

Júlio Vilmar Gesser


--
You received this message because you are subscribed to the Google Groups "JavaParser" group.
To unsubscribe from this group and stop receiving emails from it, send an email to javaparser+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

pti...@gmail.com

unread,
Mar 8, 2015, 9:38:47 AM3/8/15
to javap...@googlegroups.com
Hi!

You can find support for Java 7 and 8 sources on the active fork: https://github.com/javaparser/javaparser

Best regards,
Didier
Reply all
Reply to author
Forward
0 new messages