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

  • Home
  • SEARCH
  • 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 7916485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:49:40+00:00 2026-06-03T14:49:40+00:00

I have an OSGi bundle b1 exporting a class with public static final String

  • 0

I have an OSGi bundle b1 exporting a class with

public static final String MYVAL = "a"; //version 1

and a second bundle b2 is compiled and deployed using version 1 of b1.

Later on I change the value in b1 to

public static final String MYVAL = "b"; //version 2

but I only recompile and deploy b1, b2 is unchanged and not recompiled.

Is it possible that the b2 still sees value a at runtime?

  • 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-03T14:49:42+00:00Added an answer on June 3, 2026 at 2:49 pm

    The value of a referenced static final primitive or string is directly inlined into the using class. So unrelated to OSGI and any visibility rules, b2 will still contain an embedded MYVAL value of “a”.

    I think this is documented in the Java Language Specification, Section 13.4:

    If a field is a constant variable (§4.12.4), then deleting the keyword final or changing its value will not break compatibility with pre-existing binaries by causing them not to run, but they will not see any new value for the usage of the field unless they are recompiled. This is true even if the usage itself is not a compile-time constant expression (§15.28).

    This answer to a similar question shows a workaround. Changing the declaration so it is no longer a constant expression disables this inlining behaviour.

    public static final String MYVAL = String.valueOf("a");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the aQute Bnd toolset to create an OSGi bundle and have
I'm using netbeans, project: 'maven OSGI bundle', i have bundle activator running fine in
I have written this OSGI bundle: /* * To change this template, choose Tools
I have a 3rd party JAR that I have converted to an OSGI bundle
Using Apache Felix, I have an OSGi component I've authored that wraps some middleware
I have an Eclipse plugin for which I create the OSGi bundle JARs with
I have created an OSGi bundle with an exposed (declarative) service. If I, when
I have a Java application. I created a OSGi bundle and in Activator.start i
I have a simple CXF RS bundle deployed in Fuse 4.2 that works fine
I have an OSGi bundle that can also run in plain Java process. I

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.