Enhancement #2203

rsb-0.11+ Android compatibility / new java.lang.management requirement

Added by R. Yaghoubzadeh over 6 years ago. Updated about 6 years ago.

Status:ResolvedStart date:03/19/2015
Priority:NormalDue date:
Assignee:J. Wienke% Done:

100%

Category:Java
Target version:rsb-0.11

Description

After upgrading a 2012 Android project to rsb-0.11 (to match our non-Android projects; by replacing the jar and adapting for some API function call changes),
I could not get our app running because of the lack of java.lang.management on Android (needed by PortableProcessInfo & PortableHostInfo).
I noticed that the available classes in src/rsb/util/os are unchanged on trunk so far. Are there plans to introduce special, Android-specific util/os classes in the near future?
(Or was it my mistake / did I miss something and have to change config etc. to attain Android compatiblity now?) -thanks in advance!

android-rsb0.12-dump01.txt Magnifier - NullPtrExc, relevant section from ADT LogCat log (line 75+) (11.4 KB) R. Yaghoubzadeh, 03/19/2015 10:19 PM

Associated revisions

Revision 43e1b361
Added by J. Wienke over 6 years ago

Remove explicit dependency to java management package

Removes the explicit dependency to the java.lang.management packages and
replaces it with reflection-based access because this package is not
available on android.

  • src/rsb/util/os/PortableHostInfo.java:
    handle new exceptions and null return values
  • src/rsb/util/os/PortableProcessInfo.java:
    likewise
  • src/rsb/util/os/RuntimeOsUtilities.java:
    Use reflection to access the RuntimeMXBean instance, report errors
    when doing so to callers. Converted to real class from utility class
    for this purpose.

refs #2203

Revision 7003ae6e
Added by J. Wienke over 6 years ago

Remove explicit dependency to java management package

Removes the explicit dependency to the java.lang.management packages and
replaces it with reflection-based access because this package is not
available on android.

  • src/rsb/util/os/PortableHostInfo.java:
    handle new exceptions and null return values
  • src/rsb/util/os/PortableProcessInfo.java:
    likewise
  • src/rsb/util/os/RuntimeOsUtilities.java:
    Use reflection to access the RuntimeMXBean instance, report errors
    when doing so to callers. Converted to real class from utility class
    for this purpose.

refs #2203

Revision d7ce5b96
Added by J. Wienke about 6 years ago

Remove explicit dependency to java management package

Removes the explicit dependency to the java.lang.management packages and
replaces it with reflection-based access because this package is not
available on android.

  • src/rsb/Factory.java
    Catch exception and print warning message when activating
    introspection
  • src/rsb/introspection/IntrospectionParticipantObserver.java
    Pass through exceptions from protocol handler and document them
  • src/rsb/introspection/LacksOsInformationException.java
    New exception class to indicate missing information
  • src/rsb/introspection/ProtocolHandler.java
    Ensure that required pieces of information are available
  • src/rsb/util/os/PortableHostInfo.java:
    handle new exceptions and null return values
  • src/rsb/util/os/PortableProcessInfo.java:
    likewise
  • src/rsb/util/os/RuntimeOsUtilities.java:
    Use reflection to access the RuntimeMXBean instance, report errors
    when doing so to callers. Converted to real class from utility class
    for this purpose.

fixes #2203

History

#1 Updated by J. Wienke over 6 years ago

We did not know that these issues exist on Android. So we have to work on that. We could probably resolve this issue by using reflection for accessing the few methods of the management classes. that way, the jar does not use a symbol from these packages directly.

#2 Updated by R. Yaghoubzadeh over 6 years ago

That sounds excellent. In case that it is just a small change, is there a chance that the change will be backported to the 0.11 branch, too?

#3 Updated by J. Wienke over 6 years ago

I'm currently preparing a feature branch for that. Let's first see whether things work out. So far I can tell, that the introspection won't work on android because several pieces of information are missing in that case.

#4 Updated by J. Wienke over 6 years ago

  • Tracker changed from Support to Enhancement
  • Status changed from New to In Progress
  • Assignee set to J. Wienke

#5 Updated by J. Wienke over 6 years ago

  • % Done changed from 0 to 30

I have pushed a branch enhancement-2203. Could you compile that version and have a look whether the situation improves? I don't have any android project with RSB available, so there might be subsequent issues which is missed. Also, please try to use introspection and see what happens then. Any logging output and exception messages might be nice to see.

#6 Updated by R. Yaghoubzadeh over 6 years ago

It does run a bit further, but crashes with a NullPtr in the initializing introspection stuff (I did not add any user-set Introspection so far).
A log file is attached, maybe it suffices to inform you even without an Android project. I will gladly test more, but with delays (long weekend for Persian New Year ;) ).
The log has some warnings and then the error that causes the app to abort.

#7 Updated by J. Wienke over 6 years ago

Oh right, I forgot that introspection is enabled by default in the master version. Apart from several other things I see in the log file: Could you please try how far it goes when you disable introspection manually? Since I don't know how where the config file is read from on android, you can do this programmatically by calling rsb.Factory.getFactory().getDefaultParticipantConfig().setIntrospectionEnabled(false) as the first interaction with RSB before creating any other participants.

#8 Updated by R. Yaghoubzadeh over 6 years ago

That got rid of the error, excellent!
My app still doesn't quite work, I suspect it is a configuration issue. (Before, we used getProperties().setProperty() to set rsb host/ip directly in the app, but nothing reaches my spread daemon atm). Probably just my fault, I will report on it soon, but not tonight.

#9 Updated by J. Wienke over 6 years ago

R. Yaghoubzadeh wrote:

That got rid of the error, excellent!
My app still doesn't quite work, I suspect it is a configuration issue. (Before, we used getProperties().setProperty() to set rsb host/ip directly in the app, but nothing reaches my spread daemon atm). Probably just my fault, I will report on it soon, but not tonight.

Sounds like you are using the socket transport instead of spread. If the spread transport cannot reach the daemon, an exception should end up in the user code when sending events.

#10 Updated by J. Wienke over 6 years ago

  • Assignee deleted (J. Wienke)
  • % Done changed from 30 to 0

Lines 35 and 36 of your log file are confusing. The logging format string isn't resolved. If I test the same logging statement on my desktop, the resolution works perfectly. Do you know of any difference for java.util.logging on android?

#11 Updated by J. Wienke over 6 years ago

  • Assignee set to J. Wienke
  • % Done changed from 0 to 70

I have pushed a new version of the branch. This should also continue to operate in case the introspection is enabled. It will merely print a warning but will not crash your code.

Could you please try whether that works?

#12 Updated by J. Wienke about 6 years ago

ping

#13 Updated by J. Wienke about 6 years ago

We have pushed the new changes to master. In case you still experience an issue with enabled introspection in the master version, please reopen this issue.

#14 Updated by J. Wienke about 6 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 70 to 100

Also available in: Atom PDF