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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:01+00:00 2026-05-28T01:16:01+00:00

I have an array of bytes representing the bytes of a class file. I

  • 0

I have an array of bytes representing the bytes of a class file.

I am trying to obtain the superclass of the class that is represented by the byte array. Currently, I am using reflection of the ClassLoader class’ “defineClass” method to create a class definition of the class represented by the byte array. I then obtain the superclass by calling getSuperclass() on the newly created Class object.

Based on the superclass of the class that is represented by the byte array I need to perform bytecode transformations. Then end goal is to redefine the class represented by the byte array after its transformations.

The issue is that I cannot redefine the transformed class as its original name because two+ classes with the same name cannot be defined in the same JVM instance.

I really need to be able to make transformations based on the superclass of the class represented by the byte array and really need to redefine the transformed class with its original name.

Is there any way to obtain the superclass of a class while the class is in the form of an array of bytes? Based on the format of the .class file I would assume I could somehow “hackily” determine the superclass without defining the class as a class object and loading it into the JVM but I’m not quite sure where I would begin doing that.

Any suggestions?

  • 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-05-28T01:16:02+00:00Added an answer on May 28, 2026 at 1:16 am

    Simple, but not very efficient at runtime: Define the class in a new classloader, determine the super type, do your transformations, and define the class in the class loader of your choice. (classes loaded by different class loaders are considered distinct at runtime).

    More efficient: Use some library capable of inspecting class files such as Javassist (Tutorial), or write the extraction code yourself (check the class file specification).

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

Sidebar

Related Questions

I have a byte array that may or may not have null bytes at
I have an array of bytes representing an image in Windows BMP format and
Let's say I have array of bytes: byte[] arr = new byte[] { 0,
I have an array of bytes that I receive from an external entity. It
I have an array of bytes in my C# class, and need to persist
I have dynamic array filled with bytes, which are read from .raw file with
I have c++ code that attempts to dynamically allocate a 2d array of bytes
I have a byte array of around 10,000 bytes which is basically a blob
I have a Java class representing an event that contains some data, and also
I have an array of bytes that I read from a header section of

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.