• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interface - AbstractClass Collision

 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



Why am i getting error in above code? Please if somebody can explain underlying reason for it?
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because abstract and private are like oil and water. They do not mix
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maneesh is right. Abstract means the method is meant to be overridden, but private methods cannot be overridden (only shadowed).
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You for reply

but what about following case as there is default in class and public in interfaces and it is working fine why so? as methods are abstract both sides?

 
Matthew Brown
Bartender
Posts: 4566
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If a method is overridable at all, you can always override it with fewer restrictions. So overriding package or protected methods with public is fine.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error that you are getting looks really strange.
java.lang.ClassFormatError: Method display in class demoprograms/azrael has illegal modifiers: 0x402

It indicates that the class file is invalid. Somehow the compiler that you are using has accepted illegal code (a method that is both abstract and private) without giving an error message, and produced an invalid class file. That's a bug in the compiler.

Which compiler are you using? Is this the standard javac from the JDK (if so, what version)?
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for providing information

I am Using JDK version 6, JAVAC

what other compilers are available which compile Java Code?
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where did you get that compiler from?
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Oracle Website
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am very surprised it would allow those two modifiers together. Maybe the class was compiled with a different compiler, or (even) it has been altered after compilation. Or there was an error in transmission or recording of the .class file.
 
Azrael Noor
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BUG IN JAVA BUG IN JAVA

but i need to continue the program


 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Azrael Noor wrote:BUG IN JAVA BUG IN JAVA
I suggest you try compiling that class again, with the same version of the compiler, before you try to report a bug
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic