你是否模糊了商业Java代码?(Do you obfuscate your commercial Java code? [closed])
我想知道有没有人在自己的商业产品上使用商业/免费的java混淆器。 我只知道一个实际上在蚂蚁构建步骤中发生混淆的项目。
你模糊吗 如果是这样,为什么你会混淆?
它是真正的保护代码的一种方式,还是开发人员/管理者更好的感觉?
编辑:好的,我确切地说,关于我的观点:你是否混淆了保护你的IP(你的算法,你放在你的产品中的工作)? 出于安全考虑,我不会混淆,那感觉不对。 所以我只是在谈论保护您的应用程序代码与竞争对手。
@staffan有一个好点:
远离链接代码流的原因是,其中一些更改使得JVM无法有效地优化代码。 实际上它实际上会降低应用程序的性能。
I wonder if anyone uses commercial/free java obfuscators on his own commercial product. I know only about one project that actually had an obfuscating step in the ant build step for releases.
Do you obfuscate? And if so, why do you obfuscate?
Is it really a way to protect the code or is it just a better feeling for the developers/managers?
edit: Ok, I to be exact about my point: Do you obfuscate to protect your IP (your algorithms, the work you've put into your product)? I won't obfuscate for security reasons, that doesn't feel right. So I'm only talking about protecting your applications code against competitors.
@staffan has a good point:
The reason to stay away from chaining code flow is that some of those changes makes it impossible for the JVM to efficiently optimize the code. In effect it will actually degrade the performance of your application.
原文:https://stackoverflow.com/questions/12088
最满意答案
在Objective-C中,属性中的
copy
属性意味着合成的setter将如下所示:-(void)setMasterBirdSightingList:(NSMutableArray*)newValue { if (_masterBirdSightingList == newValue) return; // NSMutableArray* oldValue = _masterBirdSightingList; _masterBirdSightingList = [newValue copy]; // [oldValue release]; // <-- not applicable in ARC. }
并且点语法将始终转换为
[self setMasterBirdSightingList:sightingList];
无论属性的属性如何。
“分配给另一个空间以保存来自sightingList的内容”的东西是通过
-copy
方法完成的。 将参数传递给setter的newValue
参数的方式无关紧要。
编辑 :正如注释中提到的@David一样 ,可变类型的
-copy
方法返回一个不可变对象。 您必须覆盖setter才能调用-mutableCopy
。 请参阅使用可变对象的Obj-C 2.0属性的最佳方法是什么,例如NSMutableArray? 。In Objective-C, the
copy
attribute in a property means the setter synthesized will look like this:-(void)setMasterBirdSightingList:(NSMutableArray*)newValue { if (_masterBirdSightingList == newValue) return; // NSMutableArray* oldValue = _masterBirdSightingList; _masterBirdSightingList = [newValue copy]; // [oldValue release]; // <-- not applicable in ARC. }
and that dot syntax will always be translated to
[self setMasterBirdSightingList:sightingList];
regardless of the attribute of the property.
The "allocated for another space to preserve stuffs from sightingList" stuff is done via the
-copy
method. The way you pass the argument to the setter'snewValue
parameter is irrelevant.
Edit: As @David mentioned in the comment, the
-copy
method of a mutable type returns an immutable object. You have to override the setter to call-mutableCopy
instead. See What's the best way to use Obj-C 2.0 Properties with mutable objects, such as NSMutableArray?.
相关问答
更多-
@property ( nonatomic, copy ) NSArray* array 手段: - (void) setArray: (NSArray*) array { _array = [array copy]; } [array copy]总是返回一个不可变的NSArray,即使array是NSMutableArray也是如此。 @property ( nonatomic, copy ) NSMutableArray* array 处理方式有点不同: - (void) setArray ...
-
NSMutableArray的NSInternalInconsistencyException(NSInternalInconsistencyException for NSMutableArray)[2019-11-18]
使用options:NSJSONReadingMutableContainers NSJSONSerialization调用上的NSJSONReadingMutableContainers。 然后它创建的所有字典和数组都是可变的。 Use options:NSJSONReadingMutableContainers on your NSJSONSerialization call. Then all the dictionaries and arrays it creates will be mutable ... -
使用@property和'copy'属性分配NSMutableArray(assign NSMutableArray with @property and 'copy' attribute)[2019-10-14]
在Objective-C中,属性中的copy属性意味着合成的setter将如下所示: -(void)setMasterBirdSightingList:(NSMutableArray*)newValue { if (_masterBirdSightingList == newValue) return; // NSMutableArray* oldValue = _masterBirdSightingList; _masterBirdSightingList = [newValue cop ... -
这里没什么特别的。 像这样的东西: NSMutableArray *copiedData = [[self data] mutableCopyWithZone:zone]; newPlanet.data = copiedData; [copiedData release]; Nothing too special here. Something like this: NSMutableArray *copiedData = [[self data] mutableCopyWithZone:zone]; n ...
-
如果其他内容具有对同一属性的强引用,则弱属性引用很有用。 在你的情况下,似乎并非如此。 使您的Array成为一个strong属性。 (为了便于阅读,不要以大写字母开头命名变量; array稍微好于Array 。有意义的东西会更好。) A weak property reference is useful if something else has a strong reference to the same property. In your case it doesn't seem like that's ...
-
更换 Arrow a = (Arrow)[[self arrowsPkg] objectAtIndex:1]; 同 Arrow a = (Arrow)[[[self arrowsPkg] objectAtIndex:1] intValue]; 或者,写得更清楚 NSNumber *arrowNumber = [[self arrowsPkg] objectAtIndex:1]; Arrow a = [arrowNumber intValue]; 您将Arrow枚举类型存储在btn1Clicked:中的 ...
-
是的,你可以修改它的内容。 readonly只适用于指针本身 - 这样,它就不像C ++的const 。 基本上,“readonly”只是表示“不要将a.someArray = foo转换成[a setSomeArray:foo] ”。 也就是说,没有创建setter。 (当然,如果你想防止修改,你只需要使用一个NSArray 。) Yes, you can modify its contents. The readonly only applies to the pointer itself - in t ...
-
将对象从一个NSMutableArray复制到另一个NSMutableArray(copy objects from one NSMutableArray to another NSMutableArray)[2022-11-29]
你对正在发生的事情有误解。 replaceObjectAtIndex:withObject: call不修改数组中的对象,它正在修改数组本身。 在这一行之后: [self.cloneArray replaceObjectAtIndex:0 withObject:@"blah"]; 您已经替换了克隆数组中的对象,但您根本没有更改原始数组。 如果您实际修改了放入数组的NSString对象,则可能会获得您期望的行为。 但是,在示例中,您将无法使用放入原始数组的对象,因为它们是不可变的字符串对象。 如果你在那里粘 ... -
NSMutableArray线程安全(NSMutableArray thread safety)[2023-10-07]
我相信这个解决方案很差。 考虑这个: 线程#1调用count并被告知数组中有4个对象。 数组是不同步的。 线程#2调用数组上的removeObjectAtIndex:2 。 数组是不同步的。 线程#1调用objectAtIndex:3并发生错误。 相反,您需要更高级别的锁定机制,其中锁定在步骤1和5的数组周围,并且线程#2无法删除这些步骤之间的对象。 I believe this solution is poor. Consider this: thread #1 calls count and is to ... -
你应该做一个deepCopy,我使用这个并且完美地工作,由Sherm Pendley†制作 。 You should do a deepCopy, i use this one and works perfectly, made by Sherm Pendley †.