Obfuscation of protected class members - good/bad?
Hi,
there was a post regarding de-obfuscation, so i thought I�d ask a philosophical question and your opinion on another related problem.
I�ve seen an API for one product with protected methods and viriables documented in the javadoc. However, when trying to subclass API classes, it turns out that these protected methods have been obfuscated, often making meaningful subclassing impossible.
What do people think about such things? How do such practices stand from the OOP point of view? I would guess this is a bad violation...
Philip
After all, I don't understand the point of
obfuscation. The JVM was designed in a way that
de-obfuscators are always on the strong side -- The
JVM has to ensure even for obfuscated programs that
they don't do any damage to your system, so it must
(kind of) de-obfuscate them.An example of obfuscation:
before:
if (KeyValidator.validate(userKey, userName)) {
runApplication();
} else {
displayMessage("Your key is invalid, please purchace a key...");
System.exit(0);
}If you dowloaded a demo, decompiled it and looked at the code it would be easy to hack it to make it work without a key... so the creators of the code obfuscate it. This renames methods and objects, replaces strings with encryped strings transformed my a method, and throws in meaningless code:
after:
if (a(A.a).b(c, C){
x();
} else if (z.c(e.rr(0x03<<2) {
} else{
z(xlp("[2039rj[0q4q[q03q4hr[q09f[0f9h[0qwe9hf[q0we9r8[0q23f[02934");
System.exit(0);
}now that this garbage is in the middle of 1.5M of similar source code, it's no longer obvious what this does.
Similarly, obfuscated code can protect proprietary algorithms.
Similar Messages
-
Accessing inner protected class with .new
My weak understanding is that inner classes are no different in terms of access modification as other class members, thus I was expecting the following to compile:
package A;
public class ClassA {
protected void protectedMethod() {}
protected class ProtectedInnerClass {}
}is being used over here in package B
package B;
import A.*;
public class ClassB extends ClassA {
public static void main(String[] args) {
ClassB b = new ClassB();
b.protectedMethod(); // works fine. I am inheriting ClassA and calling the protected method.
ClassB.ProtectedInnerClass c = b.new ProtectedInnerClass(); // compiler error: ProtectedInnerClass is protected
}Why can I not access the protected inner class when ClassB is inheriting it as is the case with the protected method?
thanks in advance!So classes that inherit other classes with protected inner classes will not be able to instantiate these inner classes regardless of the inheritance relationship.No, that's not true. Example:
package A;
public class ClassA {
protected void protectedMethod() {
protected class ProtectedInnerClass { // class is protected
public ProtectedInnerClass() { } // <-- nota bene
package B;
import A.ClassA;
public class ClassB extends ClassA {
public static void main(String[] args) {
ClassB b = new ClassB();
b.protectedMethod(); // works fine.
ClassB.ProtectedInnerClass c = b.new ProtectedInnerClass(); // works fine, too.
}It's section 6.6.2.2 that describes this behavior, as I quoted above. The last bullet point of that section reads (to repeat): "A protected constructor can be accessed by a class instance creation expression (that does not declare an anonymous class) only from within the package in which it is defined."
~ -
hi ppl,
Iam new to this oops concept..i learnt that to access the contents of a protected class either we have call by subclass and another is with in itself.so how can we call a protected class with in class itself..pls do alter this code to call within itself
class snap definition.
protected section.
methods: m1.
data: d type char20 value 'PROTECTED'.
endclass.
class snap implementation.
method: m1.
write:/ d.
endmethod.
endclass.
start-of-selection.
data obj type ref to snap.
create object obj.
call method->m1.
end-of-selection.Hi Priyank,
Marcin's correct but there was a small typo in his post:
me->me1( ).
Is supposed to be:
me->m1( ).
as m1 is the name of the protected method. In case you're wondering, "me" is a self reference to the instance. It is not necessary, e.g. you could write just
m1( ).
but including the self reference is considered good practice because it increases the understandability of the code.
Best regards, Erik -
How to refer to a protected class outside the enclosing package
Hi all,
At the page 357 of the book Java Language Specification(Second Edition), when saying about checking accessibility of Type and Method, they concern Let C be the class containing the method invovation T.m, if T is in a different package than C, and T is protected then T is accessible if and only if C is a subclass of T. I just wonder how to refer a protected type outside the package it declared.
For example,
package test;
public class test {
static protected class protectedTest {
public void foo() {..}
in another package
import test.*;
class subtest extends test.protectedTest { <- error
Anyone can give me an example showing an invocation directly to foo() declared in class test.protectedTest ? The invocation should appear outside package test.
Thanks,
Ha ChauThe protected inner class would be accesible only within a class which extends test, where you could either use or extend it as in:
class subtest extends test {
private static class sub2 extends protectedTest {
} -
How to create an instance of a protected class outside the enclosing packag
Hi all,
I have a piece of code like this:
package test;
public class A {
protected class B { }
How to create an instance of B outside the package test ? Could you please give me an example ?
Thanks
Ha ChauThank WirajR for your reply, but in your solution,
you have to create an instance of B inside class A
and pass it outside. I would like to know whetherwe
can create an instance of class B outside thepackage
test. That means I want the instance creation
expression of B appears outside the package test.Can
we do that?
If you want to use a class this way then it shouldn't
be marked protected. I can't see why you don't
just declare it public if that's what it is.
Wouldn't be much point to haveing a protected
modifier if it had no effect, would there?I think there is use for it if you use an interface to filter out the parts you want to give public access to, and keep the part you want to keep protected, protected -
Class in standard BAdI not impelementing in the Development Server
Hi All,
I have been trying to implement a class in BAdI in Development Sever, yet couldnot find the reason why it is not implementing.
BAdI name - ME_PROCESS_PO_CUST
I have implemented a class in that BAdI. In that class, I have used a method to write the code.
Even when I keep the Breakpoint inside the method and then try to create a PO using ME21N, I was not to call method.
I have activated the class and the method as well.
Suggest me where I went wrong.
Thanks in advance,
Ravi Teja
Edited by: Ravi Teja P on Sep 26, 2011 12:41 PMRavi,
If you have created a Classical BADI implementation, then better Go for New Enhancement Implementation for it.
'ME_PROCESS_PO_CUST' is also a Enhancement Spot, hence use se19 to create an Enh Implementation for it, a BADI implementation, an implementing class and code your logic inside the method of your implementing class.
Activate all 4 components and this should be surely triggered.
Regards,
Diwakar -
How to call a ABAP proxy class from a BADI? Please help!
hi Experts,
I have a scenario where I have to call a ABAP proxy class from a BADI. How can I do this? Does anybody has sample code for the same?
Please help.
Thanks
GopalHi Gopal,
Check this out
DATA: ref_obj TYPE REF TO zmfg_production_ord.----> BADI
* Instantiate the proxy class
CREATE OBJECT ref_obj.
TRY.
CALL METHOD ref_obj->execute_asynchronous
EXPORTING
output = it_output. "Output Structure
COMMIT WORK.
CATCH cx_ai_system_fault INTO ref_sysexception.
ENDTRY.
IF ref_sysexception IS INITIAL.
WRITE : / 'Error Message'.
ENDIF.
Edited by: Raj on May 28, 2008 4:52 PM -
Customize class members and methods showed by IDE
Is anyway to customize the output of the class members and methods show by IDE when you code a class?
In detail:
If you have a class A:
A myClass = new A();
and you tipe myClass.
then the IDE show you a list of class members and methods in a Dialog Box....
can you customize these????????
I want to set another output for these....
Thanks!That's not the meaning of the question.....
When someone work with a Java IDE and are editing source, the IDE help you writing code showing you the members and methods of the object that you are working on, like these:
a.------------------------
| void setX(int x) |
| void setY(int y) |
These information is provided by the IDE. I think that it makes a special type of introspection on classes ..... but a really strong one, because it can access to private members and methods....
I want to customize these behaviour....... and i want the IDE's show only the strings that i want....
For exemple:
a.------------------------
| to establish X |
| to establish Y |
Thanks! -
Error: No public or protected classes found to document.
Hello,
I am currently going spare trying to get javadoc to document the code I have written. I have checked the Java code given the information on the website and the comments are correct and complete for all methods. The command line I am using is:
c:\j2sdk1.4.1_01\bin\javadoc.exe -d docs/ Population.javaAnd the makefile (bat file) is in the directory with the population.java file. The command line works with other files in the same directory, programmed and commented to the same standard. The error I get is:
C:\Documents and Settings\ril\MYDOCU~1\PROGRA~1\JCreator\ILCSFrame>c:\j2sdk1.4.1_01\bin\javadoc.exe -d docs/ Population.java
Loading source file ILCSFrame.java...
Constructing Javadoc information...
Standard Doclet version 1.4.1
Generating docs/\constant-values.html...
javadoc: No public or protected classes found to document.
1 errorI have tried checking the documentation with the doccheck doclet with the following command line:
c:\j2sdk1.4.1_01\bin\javadoc.exe -doclet com.sun.tools.doclets.doccheck.DocCheck -docletpath C:\j2sdk1.4.1_01\utils\doccheck1.2b1\lib Population.javaBut it throws the following error:
C:\Documents and Settings\ril\MYDOCU~1\PROGRA~1\JCreator\ILCSFrame>c:\j2sdk1.4.1
_01\bin\javadoc.exe -doclet com.sun.tools.doclets.doccheck.DocCheck -docletpath
C:\j2sdk1.4.1_01\utils\doccheck1.2b1\lib\doccheck.jar Population.java
Loading source file Population.java...
Constructing Javadoc information...
javadoc: In doclet class com.sun.tools.doclets.doccheck.DocCheck, method start
has thrown an exception java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodError: com.sun.tools.doclets.HtmlWriter.<init>(Ljava/lang/
String;Ljava/lang/String;)V
at com.sun.tools.doclets.doccheck.HtmlWriterExt.<init>(HtmlWriterExt.jav
a:16)
at com.sun.tools.doclets.doccheck.DocCheck.makeWriter(DocCheck.java:1407
at com.sun.tools.doclets.doccheck.DocCheck.printStatisticsPage(DocCheck.
java:456)
at com.sun.tools.doclets.doccheck.DocCheck.printErrorPages(DocCheck.java
:433)
at com.sun.tools.doclets.doccheck.DocCheck.startGeneration(DocCheck.java
:364)
at com.sun.tools.doclets.doccheck.DocCheck.start(DocCheck.java:337)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:193)
at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:92)
at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:301)
at com.sun.tools.javadoc.Start.begin(Start.java:120)
at com.sun.tools.javadoc.Main.execute(Main.java:41)
at com.sun.tools.javadoc.Main.main(Main.java:31)
1 errorIf I try running doccheck (without doclet) on the whole directory (containing 6 java files), it will only pick up 3 of them (one including the SwingWorker java file). Any help greatly appreciated."No public or protected classes found to document" means
that the class Population.java is not in the current directory.
Without trying to insult your programming ability, these things
come to mind:
- Omit the slash at the end of "-d docs/" This causes the
message "Generating docs/\constant-values.html.
I'm not sure why the bat file uses a forward slash on
a Windows system.
- Make sure you cd to the directory containing the bat file before
running it.
- Java is case-sensitive (I notice you spelled the filename
both uppercase and lowercase.) Make sure the file name,
the class name in the class, and the class name in the bat
file have the same case.
As far as doccheck not running, we have not yet released the
version that runs on 1.4.x. Please write to "doccheck-feedback"
with "@sun.com" for more info. (I've broken up the email address
so text crawlers won't get it.)
-Doug Kramer
Javadoc team -
Oracle 11g R2 Instance Caging on Linux 64-bit? Good, Bad, Ugly.
Hello everyone
I hope this is the correct forum, if not please advise best place to post this question.
I am thinking of using Oracle 11g R2 Enterprise Edition running on 64-bit Linux server (Oracle Linux 6.x or Red Hat Linux 6.x) with Resource Manager Instance Caging feature enabled to consolidate about 20 databases on one larger Intel-X64 server (40 cores, 512RB RAM, SAN). RAC is not needed but RAC One Node may be one other possible option as will also be Data Guard 11g R2 for HA/DR.
I am looking for opinions from those who have used and implemented Instance Caging feature in production on 11g R1 or 11g R2 on Linux/UNIX 64-bit OS - please share your experiences - good, bad, ugly ?
Any recent whitepapers and studies on 11g R2? I have seen some information dating back to 11g R1 (~2009), hoping there are some 11g R2 updates on this topic for 2010-2012.
Please provide pointers if you know of any.
Has anyone implemented Instance Caging on RAC One Node (or full RAC)? Opinions?
thanks.
Yuri B
Edited by: yurib on Aug 28, 2012 12:08 PMCheck This
NOTE:1339769.1 - Master Note for Oracle Database Resource Manager
Configuring and Monitoring Instance Caging [ID 1362445.1] -
Hiding of super class members in subclass
I want to hide super class members in subclass. like this
class super{
public int method(){
class sub extends super{
public string method(){
give any solution for this criteria, I cann't make methods as privateIn java there is no way to override
the methodsThat's incorrect. You can override methods in Java.
However, you cannot do what the OP is trying to do. -
Okay, I have established a network using four AP Extremes. Three are extended off a base station that is connected to Comcast. Distance between extremes are about 50 feet each.
The length of the need for a network is about a football field with two story condo buildings along the sideline. I have placed the Extremes in the window stills in direct line with either other. Using 2.4 GHZ with automatic radio. Buildings are concrete with windows that are length of room. I have encourage folks to get extenders to place at their windows to extend beyond the front of the window.
If I am right we are talking at least 300 feet total, if that's the length of the football field.
Two of the units seem to get weak and give off poor signal. We have problems with the signal going in and out thus causing some outage and gaps in the service. It appears its worst at night.
Good, bad or average? Any suggestion on improving the network's signal so people don't have gaps in the signal? Is there another source of devices that can be used that not a commerical grade (expensive) and can be easily installed?
Thanks.Please check out the following AirPort User Tip for details on how to best place each of your AirPort base stations.
-
Wells Fargo good, bad, or just not going to happen?
We applied with WF and got pre approved-- they ran credit (loan only in husbands name) and took verbal info. Approved on the spot, no worries, we were told.
I can't help but feel like this is all a joke, especially after reading on here.
Here's what I got:
Mid score 642
2 cc lates 1/15 and 5/15
One medical collection $900
DTI - 5% car- $475 cc- $200 min payments
Income- 175,000 salary (new company, same field for 10+years, similar pay scale for 4 years)
New York, single family home, $237,500 purchase price, primary residence.
Pre approved for conventional (house won't meet FHA requirements 100yr old house)
Actual Interest Rate
5.000%
Actual Rate Type
Fixed Rate
Actual Monthly Payment (P&I + MI)
$1,461.92 does not include taxes and insurance
Principal Repayment Type
Fully Amortized
Maturity Term
360
I have no idea what I'm looking at. Is this good bad, for real? This happened too fast and I can't catch up!Patriceandjosh wrote:
We applied with WF and got pre approved-- they ran credit (loan only in husbands name) and took verbal info. Approved on the spot, no worries, we were told.
I can't help but feel like this is all a joke, especially after reading on here.
Here's what I got:
Mid score 642
2 cc lates 1/15 and 5/15
One medical collection $900
DTI - 5% car- $475 cc- $200 min payments
Income- 175,000 salary (new company, same field for 10+years, similar pay scale for 4 years)
New York, single family home, $237,500 purchase price, primary residence.
Pre approved for conventional (house won't meet FHA requirements 100yr old house)
Actual Interest Rate
5.000%
Actual Rate Type
Fixed Rate
Actual Monthly Payment (P&I + MI)
$1,461.92 does not include taxes and insurance
Principal Repayment Type
Fully Amortized
Maturity Term
360
I have no idea what I'm looking at. Is this good bad, for real? This happened too fast and I can't catch up!
Start writing your LOX for the lates and collections. Make sure they have all your documents within the first week. The monthly payment for a 100 year old house is too high. I think you all should wait to get your score up for a better rate. 5% for the amount you're borrowing is too high compared to the average APR being 4.04% now. Ar you planning to live in the home forever? May be hard to sell a home that is 100 years old unless you do some extensive remodeling. -
How to check the show base class members in teststand programatically using c#
I need to check the checkbox indicating show base class members in teststand using .Net adapter programatically through c#.can I get any help.Using CallMethod , I need to call a method "GetItemByName" .It is only possible by enabling the show Base Class Members checkbox.Any Help?
Attachments:
ex2.gif 2305 KBbannerghatta -
This is specified by the DotNetModule.MemberFlags property. The DotNetMemberFlags consist of DotNetMemberFlags_Static (0x1) and DotNetMemberFlags_TopLevel (0x2). These can be used individually or you can perform a Bit-Wise OR to use them together.
In your case, the Show Base Class Members check box corresponds to the DotNetMemberFlags_TopLevel (0x2). If this flag is set, the box is not checked. If the flag is not set, the box is checked. Thus, you will either want to set DotNetModule.MemberFlags = 0x0 or 0x1 dependent on whether or not you are using a Static Member.
Since you seem to be doing a lot with the DotNetModule, here is a link to the DotNetModule Help online.
Hope this helps.
Message Edited by Manooch_H on 01-07-2010 09:27 AM
Manooch H.
National Instruments -
How to protect protected classes?
I�m Brazilian, and I am learning English language yet. I�ll try to describe my problem.
I am using protected and friendly classes, but it doesn�t avoid anyone to use them, because if someone knows the package name of my protected class, this person can create a class with the same name of the package, and my protected and friendly classes are now unprotected! Anyone can instantiate my classes in this way.
Did anyone go through this situation? Is there solution for it?
Thank you so much!There is a solution. I created the same post in Programming section of this forum, that is more apropriate, and there a user called Shag-VT posted a solution.
The way to ensure that nobody is getting into your classes is to "seal" the >package in the manifest and then sign the jar with a digital signature.
The followng like contains a discussion of how to add a digital signature to the >jar (it's just the general documentation for a jar file):
http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html
It also has a link to another file, which shows how to seal the package. For >convenience, here is the link:
http://java.sun.com/j2se/1.4.2/docs/guide/extensions/spec.html#sealing
Maybe you are looking for
-
I am using SharePoint 2013. I have mapped several network drives. When adding files off SharePoint to an Outlook email, I can only add one file at a time. I can add multiple files IF they are not on SharePoint (e.g., stored locally, or on Dropbox); P
-
Total of the ordered quantity in sales order
Hi Is there any settings or functionality for the totalling of the order quantity in the sales order as the user requires to see the total number of the units of quantity of order taken and if its less they can still ask for more order from the custo
-
I tried to register my name and purchase information with the up-to-date program but the site says my serial number is already registered. So am I already available for the upgrade? Or did some little punk at futureshop rip off my serial number?
-
Can't get Windows 7 to recognize my keyboard, usb drives, nor the mouse pad on my MacBook Pro. Have settup Bootcamp division and loaded Win 7. Apparantly the needed drivers did not load. How do I deal with this issue? Thanks.
-
Adobe PDF/Acroforms & Digital signatures/Integrity/Authentication/Non repudiation
Hi folks, I have been investigation the feasibility of using PDF as a customer-facing data collection mechanism, starting with Acroforms for a pilot, initially at least (we may consider XFA/Livecycle in a later phase). I've got a demo application up