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 8072743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:07:14+00:00 2026-06-05T14:07:14+00:00

In my Android application, i have the following classes: public abstract class A implements

  • 0

In my Android application, i have the following classes:

public abstract class A implements IA {
    private void findAnnotations() {
        Field[] fields = getClass().getFields();

        // Get all fields of the object annotated for serialization
        if (fields != null && fields.length > 0) {
            for (Field f : fields) {
                Annotation[] a = f.getAnnotations();

                if (annotation != null) {
                    // Do something
                }
            }
        }

        return serializationInfoList
                .toArray(new SoapSerializationFieldInfo[serializationInfoList
                        .size()]);
    }
}

and

public abstract class B extends A {
    @MyAnnotation(Name="fieldDelaredInB")
    public long fieldDelaredInB;
}

When i call B.findAnnotations(), i can see that getClass().getFields() returns the fields declared in B – fieldDelaredInB, e.g., but no annotations for these fields are returned – i.e, i get null when i call f.getAnnotations(), f.getDeclaredAnnotations() or whatsoever.

Is this an issue of a superclass unfamiliar with attributes of derived classes? seems weird, considering the fact that the fields of the derived class DO appear when i call getFields() from the superclass.

Any ideas of what am i missing?

Thanks,
Harel

  • 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-05T14:07:16+00:00Added an answer on June 5, 2026 at 2:07 pm

    An annotation is not loaded at runtime unless it is marked for runtime retention with @Retention(RetentionPolicy.RUNTIME). You must place this @Retention annotation on your @MyAnnotation annotation:

    @Retention(RetentionPolicy.RUNTIME)
    public @interface MyAnnotation {
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an Android application. I have the following interface: public interface IDBAdapter {
I have the following code in an Android application: public static HttpResponse dbPost(String handlerUrl,
In my android application, I have following requirement. Activity A --> Activity B(Go to
to send a message in my application in android i have used the following
I have the following XML layout in my android application, using ScrollView: <?xml version=1.0
In my android application I have an activity containing a Parcelable object (implements Parcelable
I have following layout in my android application. <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/mainlayout android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent
I have the following problem: I am working on an Android application where at
I'm developing an Android application. I have the following vertex shader. attribute vec4 vertexPosition;
I have the following application.xml <?xml version=1.0 encoding=utf-8?> <manifest xmlns:android=http://schemas.android.com/apk/res/android package=com.currency.mobile.android> <uses-permission android:name=android.permission.INTERNET/> <application

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.