Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create default method in an interface #137

Open
malvee opened this issue May 16, 2017 · 3 comments
Open

Cannot create default method in an interface #137

malvee opened this issue May 16, 2017 · 3 comments

Comments

@malvee
Copy link

malvee commented May 16, 2017

I am trying to generate the whole interface file at runtime and I need to add just 1 default method which calls other methods added to the CtClass before. The exception I get:
Exception in thread "main" javassist.CannotCompileException: [source error] syntax error near "**default Object** get" at javassist.CtNewMethod.make(CtNewMethod.java:79) at javassist.CtNewMethod.make(CtNewMethod.java:45) Caused by: compile error: syntax error near "**default Object get**" at javassist.compiler.Parser.parseClassType(Parser.java:984) at javassist.compiler.Parser.parseFormalType(Parser.java:192) at javassist.compiler.Parser.parseMember1(Parser.java:52) at javassist.compiler.Javac.compile(Javac.java:90) at javassist.CtNewMethod.make(CtNewMethod.java:74)
Whats the correct way to add default methods to an interface. The interface was made using makeInterface, and I am adding the default as .addMethod(CtNewMethod.make("default ....", interface))
I am using 3.12.1.GA from maven repo. Thanks.

@chibash
Copy link
Member

chibash commented May 16, 2017

Maybe you don't need "default" in the source...

@malvee
Copy link
Author

malvee commented May 17, 2017

I checked and I am using 3.20 now, so that does have Java8 support. Found another issue which seems to have been resolved but I am getting the exact same problem:
#104

@PastelBelem8
Copy link

PastelBelem8 commented Mar 5, 2018

I'm currently using version 3.22 and I cannot create default methods in interfaces at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants