In my jsp file there is a line:
byte[] imageData = Base64.decodeBase64(request.getParameter("imageBase64"));
and eclipse complains:
The method decodeBase64(byte[]) in the type Base64 is not applicable for the arguments (String)"
It says that the method gets a String
, but it expects a byte[]
.
But in the Base64
class there are two overloaded versions of decodeBase64
; one with argument String
,
and one with argument byte[]
.
I fail to see why the compiler seems to think I am calling the byte[]
version with an incorrect String
argument, where it should have used the String
version without any compiler error.
The compiler distinguishes overloaded methods by their signatures—a combination of the method's name and the number, types and order of its parameters, but not its return type. If the compiler looked only at method names during compilation, the code in Fig.
Explanation: Overloading is determined at compile time. It is also called as compile time polymorphism.
Base64
class in package org.apache.commons.codec.binary
has 2 decode methods
static byte[] decodeBase64(byte[] base64Data) since beginning
static byte[] decodeBase64(String base64String) since version 1.4.
I think you must be having jar prior to commons codec 1.4
in your classpath
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With