Re: JNA and ProGaurd

212 views
Skip to first unread message

Timothy Wall

unread,
Jul 17, 2012, 6:37:10 PM7/17/12
to Andrew Green, jna-...@googlegroups.com
Why don't you simply exclude everything from jna.jar from being obfuscated?

You may need to apply more settings than simply keep-class (preserve/keep members?). You should probably also keep the jna.jar separate in your distribution; it also makes it easier to swap in JNA updates.

You'll also need to avoid obfuscating any classes extending Structure, since JNA uses reflection extensively on that class and its descendants.

I've used ProGuard before but I don't recall their options and they've likely changed since then anyway.

Someone (either on this list or stackoverflow) had a similar question re: ProGuard; search both places for additional info.

On Jul 17, 2012, at 11:45 AM, Andrew Green wrote:

> Hi Tim,
>
> It’s me again. Your library has been very helpful up to now but I obfuscate all my programs before deploying them. I use ProGuard (the GUI) to do this but it is throwing up lots of errors – see below for an example:
>
> Maybe this is library method 'sun.security.x509.X509CertInfo { int hashCode(); }'
> Maybe this is library method 'sun.security.x509.X509Key { int hashCode(); }'
> Maybe this is library method 'sun.swing.BakedArrayList { int hashCode(); }'
> Maybe this is library method 'sun.swing.SwingUtilities2$LSBCacheEntry { int hashCode(); }'
> Maybe this is library method 'sun.swing.text.TextComponentPrintable$IntegerSegment { int hashCode(); }'
> Maybe this is library method 'sun.text.CompactByteArray { int hashCode(); }'
> Maybe this is library method 'sun.text.IntHashtable { int hashCode(); }'
> Maybe this is library method 'sun.util.BuddhistCalendar { int hashCode(); }'
> Maybe this is library method 'sun.util.PreHashedMap$2$1$1 { int hashCode(); }'
> Maybe this is library method 'sun.util.calendar.CalendarDate { int hashCode(); }'
> Maybe this is library method 'sun.util.calendar.Era { int hashCode(); }'
> Maybe this is library method 'sun.util.calendar.ImmutableGregorianDate { int hashCode(); }'
> Maybe this is library method 'sun.util.calendar.ZoneInfo { int hashCode(); }'
> Maybe this is library method 'sun.util.locale.BaseLocale { int hashCode(); }'
> Maybe this is library method 'sun.util.locale.BaseLocale$Key { int hashCode(); }'
> Maybe this is library method 'sun.util.locale.InternalLocaleBuilder$CaseInsensitiveChar { int hashCode(); }'
> Maybe this is library method 'sun.util.locale.InternalLocaleBuilder$CaseInsensitiveString { int hashCode(); }'
> Maybe this is library method 'sun.util.locale.LocaleExtensions { int hashCode(); }'
> Note: com.sun.jna.Native accesses a field 'OPTIONS' dynamically
> Note: com.sun.jna.Native accesses a field 'TYPE_MAPPER' dynamically
> Note: com.sun.jna.Native accesses a field 'STRUCTURE_ALIGNMENT' dynamically
> Note: the configuration keeps the entry point 'com.engines.AppUserModelID { com.sun.jna.NativeLong SetCurrentProcessExplicitAppUserModelID(com.sun.jna.WString); }', but not the descriptor class 'com.sun.jna.WString'
> Note: the configuration keeps the entry point 'com.sun.jna.Native { long registerMethod(java.lang.Class,java.lang.String,java.lang.String,int[],long[],long[],int,long,long,java.lang.Class,long,int,boolean,com.sun.jna.ToNativeConverter[],com.sun.jna.FromNativeConverter); }', but not the descriptor class 'com.sun.jna.ToNativeConverter'
>
> I have specified for it to keep the class “com.sun.jna.**” which extends “**” etc. but I have had no luck. Have you experienced this before and/or know what to do?
>
> Thanks and kind regards

Reply all
Reply to author
Forward
0 new messages