Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:17:39+00:00 2026-06-13T02:17:39+00:00

I have strange behavior of the static final values in my interface: public interface

  • 0

I have strange behavior of the static final values in my interface:

public interface IDictionaryErrorTypes {

    final static int ERROR_UNKNOWN      = 0;
    final static int ERROR_XML      = 1;
    final static int ERROR_CONNECTION   = 3;

}

public interface IDictionaryListModel extends IDictionaryErrorTypes,
                                                    //... and other interfaces
{

}

public class DictionaryListModel implements IDictionaryListModel {

// ... some code ...

private int getErrorCode(Exception error) {
    // determinate the error code
    if (error instanceof ParserConfigurationException
            || error instanceof SAXException
            || error instanceof SAXParseException) {
        return ERROR_XML;
    } else if (error instanceof UnknownHostException
            || error instanceof MalformedURLException
            || error instanceof IOException) {
        return ERROR_CONNECTION;
    } 
    return ERROR_UNKNOWN;
}

And now when I run the application ERROR_XML, ERROR_CONNECTION and ERROR_UNKNOWN values equals ZERO – 0. It seems to me very strange. Please look at attached image

java static fields interface bug

If I use in my model IDictionaryErrorTypes.ERROR_CONNECTION it still has the same behavior. But if I remove the "implements IDictionaryErrorTypes" and then use IDictionaryErrorTypes.ERROR_CONNECTION it works – constant values are exactly as they sound be.

When I use class instead of interface it also works fine.

Can someone explain this behavior? (p.s. Im using android platform)

p.s.(2) I also experimented by adding/removing “final”, “static”, “public” keywords ( That is why interface declaration in the image and code about a little bit differ). But behavior is the same

smali code of the WORKING VERSION (using class instead of interface):

.method private getErrorCode(Ljava/lang/Exception;)I
    .registers 3
    .parameter "error"

    .prologue
    .line 145
    instance-of v0, p1, Ljavax/xml/parsers/ParserConfigurationException;

    if-nez v0, :cond_c

    .line 146
    instance-of v0, p1, Lorg/xml/sax/SAXException;

    if-nez v0, :cond_c

    .line 147
    instance-of v0, p1, Lorg/xml/sax/SAXParseException;

    if-eqz v0, :cond_e

    .line 148
    :cond_c
    const/4 v0, 0x1

    .line 154
    :goto_d
    return v0

    .line 149
    :cond_e
    instance-of v0, p1, Ljava/net/UnknownHostException;

    if-nez v0, :cond_1a

    .line 150
    instance-of v0, p1, Ljava/net/MalformedURLException;

    if-nez v0, :cond_1a

    .line 151
    instance-of v0, p1, Ljava/io/IOException;

    if-eqz v0, :cond_1c

    .line 152
    :cond_1a
    const/4 v0, 0x3

    goto :goto_d

    .line 154
    :cond_1c
    const/4 v0, 0x0

    goto :goto_d
.end method

// class instead of interface

.class public Ltj/zar/projects/kathtranslator/interfaces/common/IDictionaryErrorTypes;
.super Ljava/lang/Object;
.source "IDictionaryErrorTypes.java"


# static fields
.field public static final ERROR_CONNECTION:I = 0x3

.field public static final ERROR_UNKNOWN:I = 0x0

.field public static final ERROR_XML:I = 0x1


# direct methods
.method public constructor <init>()V
    .registers 1

    .prologue
    .line 3
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

smali code of the UNWORKING VERSION:

.method private getErrorCode(Ljava/lang/Exception;)I
    .registers 3
.parameter "error"

.prologue
.line 145
instance-of v0, p1, Ljavax/xml/parsers/ParserConfigurationException;

if-nez v0, :cond_c

.line 146
instance-of v0, p1, Lorg/xml/sax/SAXException;

if-nez v0, :cond_c

.line 147
instance-of v0, p1, Lorg/xml/sax/SAXParseException;

if-eqz v0, :cond_e

.line 148
:cond_c
const/4 v0, 0x1

.line 154
:goto_d
return v0

.line 149
:cond_e
instance-of v0, p1, Ljava/net/UnknownHostException;

if-nez v0, :cond_1a

.line 150
instance-of v0, p1, Ljava/net/MalformedURLException;

if-nez v0, :cond_1a

.line 151
instance-of v0, p1, Ljava/io/IOException;

if-eqz v0, :cond_1c

.line 152
:cond_1a
const/4 v0, 0x3

goto :goto_d

.line 154
:cond_1c
const/4 v0, 0x0

goto :goto_d
.end method

// interface

.class public interface abstract Ltj/zar/projects/kathtranslator/interfaces/common/IDictionaryErrorTypes;
.super Ljava/lang/Object;
.source "IDictionaryErrorTypes.java"


# static fields
.field public static final ERROR_CONNECTION:I = 0x3

.field public static final ERROR_UNKNOWN:I = 0x0

.field public static final ERROR_XML:I = 0x1

solve

Ive cleaned up the project, changed emulator to real device and wrote some test.

Results

It seems a debugger problem:

As you can see in the image error is “3” and ERROR_CONNECTION is “0”. And device actually runs the next string (green string), that means that debugger thinking that 3 == 0, but actually its 3 == 3

Conclusion

Debugger bug.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:17:40+00:00Added an answer on June 13, 2026 at 2:17 am

    I think that the only possible explanation is that you have something broken in you edit / build / run / debug procedures, and you are actually running a different version of the code than you think you are.

    The evidence for this is that you have decompiled the two versions of the class that you believe that you are running, and the decompiled code clearly shows that:

    1. it is using inlined constant values, and
    2. the constant values are the ones that you expect.

    But when you execute the code (supposedly) it clearly behaves differently to what those bytecodes say.

    I can only see one plausible explanation: you are not executing those bytecodes. Instead, you are executing a different version of the bytecodes. In short, you are not recompiling / rebuilding / redeploying everything that needs to be … done.

    The debugger output is interesting because it tends to confirm this hypothesis, in that it seems to say that your executable has a copy of the interface with constants that are different from what your source code says. (It could also be a debugger bug … but that is too large a coincidence.) However, the debugger output itself doesn’t explain the behaviour of your app, because the app is not using those values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class, class MyClass { private int val; public static final MyClass
I have strange gyroscope behavior: I have values[0] from gyroscope sensor: Angular speed around
I have realy strange behavior. I have this code (I remove unrelated code). $(function()
I have this strange behavior in my JSP page: I have two Integer variables
I have some strange behavior redirecting stdout and stderr from s3cmd. For example: $
I have a strange behavior with my WPF ListView Control. ListViews ItemSource is Observable
I have trouble with strange behavior of for..in cycle in JavaScript. I have the
I have a very strange behavior with Request.Form . Here are two IIS 7
I have a really strange behavior with highchart (via rails plugin): The graph display
I have a horizontal animated menu that has a strange behavior because it works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.