- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
背景:
内部
方法TLDR:如果方法是公开的,我如何指示(或更好地保护)我的 API 的内部方法不被 API 类之外的用户调用?
典型例子:
// public class in com.ashes999.components
class SpriteComponent {
// This method should be internal
public void dispose() { ... }
}
// public class in com.ashes999.management
class SceneManager {
public void changeScene(Scene s) {
for (SpriteComponent s : this.allEntities.allSprites) {
s.dispose();
}
}
}
我只会从 com.ashes999.*
中我自己的类调用 SpriteComponent.dispose
。我永远不会期望(甚至希望)其他用户会直接调用它;这样做会导致困惑、破坏、困惑和过早处置未管理的资源,从而导致崩溃。
最佳答案
A class may be declared with the modifier public, in which case that class is visible to all classes everywhere. If a class has no modifier (the default, also known as package-private), it is visible only within its own package (packages are named groups of related classes — you will learn about them in a later lesson.)
At the member level, you can also use the public modifier or no modifier (package-private) just as with top-level classes, and with the same meaning. For members, there are two additional access modifiers: private and protected. The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.
( Access control )
关于java - 如何避免使用内部方法污染 API 类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25296777/
我正在尝试将我的插件提交到 mozilla 站点,但我收到了这个该死的警告: 代码(在 mf_options.js 中)非常简单(我认为问题只存在于“开始存储”和“结束存储”之间: // start
精简版 在下面的代码中,$1被污染了,我不明白为什么。 长版 我在运行 Foswiki在带有 -T 的 perl v5.14.2 系统上启用污点检查模式。 调试该设置的问题,我设法构建了以下 SSCC
我有一个 Controller ,其中 $scope 对象已用于存储仅在同一 Controller 中本地使用的方法和值。有很多这样的事情发生: $scope.foo = 'something'; $
我知道将不受信任的对象标记为受污染的可能性,但根本目的是什么,我为什么要这样做? 最佳答案 将污点作为一种安全预防措施进行跟踪,以确保不受信任的数据不会被错误地用于计算、交易或解释为代码。 通过内置语
我正在开始一个新的 react 项目,我刚刚安装了非常基本的包(npx create-react-app),没有任何其他东西。当我运行审核时,我得到以下低漏洞:
我知道关于这个特定主题有很多,但是我找不到任何偶然发现我的问题的人,希望有人可以向我解释这一点。 我有一个域,我在 equals 方法中使用注入(inject)的 grailsApplication
我在程序中使用许多不同的记录,其中一些使用相同的字段名称,例如 data Customer = Customer { ..., foo :: Int, ... } data Product = Pro
我有一个包含 2 个节点组的集群:实时和常规。我只希望能够实时容忍亲和性的 Pod 能够在来自实时集群的节点上运行。 我的方法是污染相关节点并向我要注册到该节点的 pod 添加容忍度。当我试图污染一个
在其中一个回复中,BalusC 已经提到了 初学者的一个常见错误是,他们将 servletcontainer/appserver 的库复制到/WEB-INF/lib 中,因为他们在 IDE 中遇到编译
最近我偶然发现了一个vulnerability in doT.js 。该漏洞的存在是因为攻击者可以利用原型(prototype)污染来修改传入 doT 的选项值。 示例: var doT = requ
我有一个带有多个命名空间的仅 header C++ 库。 例如一个头文件可能包含 //header1.h namespace library{ namespace componentA{ tem
我正在尝试将 svg 转换为图像并提示用户下载。 var chart = $(svg.node()) .attr('xmlns', 'http://www.w3.org/200
在 javascript 中,可以“覆盖”Object.prototype 的属性或方法。例如: Object.prototype.toString = function(){ return "s
当我们要写入一个数据项时,首先将包含数据的块带入缓存,然后将数据项写入缓存。这可能会导致缓存污染。为了避免这种情况,英特尔没有引入临时指令。 如果我要使用 mmap() 将数据写入文件并且永远不会再次
我可以感染一个节点,但不能感染一个实例组。 kubectl taint nodes nodeA kops.k8s.io/instancegroup=loadbalancer:NoSchedule 下面
我的应用程序显示存储在 中的图像AWS S3 (出于安全原因,在私有(private)存储桶中)。 为了让用户从他们的浏览器中看到图像,我生成了 签名 URL 喜欢 https://s3.eu-cen
总结 对于我的 CS 顶点项目,我们遇到了一个类名存在于两个不同依赖项中的问题。具体来说,我们使用一个依赖项将 MySQL 与 Entity Frame 一起使用,一个用于直接连接和执行 MySQL
我在 VS 2005 中有一个 VC++ 项目,我制作了 32 位和 64 位版本。我刚刚安装了 VS 2010 并试图将项目移植到较新的 Visual Studio。它不会移植,因为该项目引用了平台
我正在使用 Struts 2 v 2.3.16.3 和 tomcat 6。 用户将单击一个通过 id 查找对象的操作,页面将显示它。我遇到了一个零星的错误,用户会突然从另一台机器上的另一个用户那里得到
这个问题已经有答案了: Tainted Canvas, due to CORS and SVG? (2 个回答) 已关闭 4 年前。 我在 Angular JS 中有一个指令,允许将 SVG 导出为
我是一名优秀的程序员,十分优秀!