tods5eshoes
Ununokt
Dołączył: 23 Lut 2011
Posty: 18577
Przeczytał: 0 tematów
Ostrzeżeń: 0/5 Skąd: England
|
Wysłany: Wto 3:39, 15 Mar 2011 Temat postu: timberland outlet store 6241 |
|
|
Building Secure Applets with Java
Java programs do not use pointers explicitly. Objects are accessed by getting a handle to the object. Effectively, this is like getting a pointer to an object,[link widoczny dla zalogowanych], but Java does not allow the equivalent of pointer arithmetic on object handles. Object handles cannot be modified in any way by the Java applet or application.
C and C++ programmers are used to manipulating pointers to implement strings and to implement arrays. Java has high-level support for both strings and arrays, so programmers don't need to resort to pointer arithmetic in order to use those data structures.
Arrays are bounds-checked at runtime. Using a negative index causes a runtime exception, and using an index that is larger than the size of the array causes a runtime exception. Once an array object is created, its length never changes.
Strings in Java are immutable. A string is zero or more characters enclosed in double quotes, and it's an instance of the String class. Using immutable strings can help prevent common runtime errors that could be exploited by hostile applets.
The Java compiler checks that all type casts are legal. Java is a strongly typed language,[link widoczny dla zalogowanych], unlike C or C++, and objects cannot be cast to a subclass without an explicit runtime check.
The final modifier can be used when initializing a variable,[link widoczny dla zalogowanych], to prevent runtime modification of that variable. The compiler catches attempts to modify final variables.
Before a method is invoked on an object, the compiler checks that the object is the correct type for that method. For example,[link widoczny dla zalogowanych],
invoking t.currentThread() when t is not a Thread object causes a compile time error.
Java provides four access modifiers for methods and variables defined within classes and makes sure that these access barriers are not violated.
public: a public method is accessible anywhere the class name is accessible
protected: a protected method is accessible by a child of a class as long as it is trying to access fields in a similarly typed class.
For example,
class Parent { protected int x; }
class Child extends Parent { ... }
The class Child can access the field "x" only on objects that are of type Child (or a subset of Child.)
private: a private method is accessible only within its defining class
default: if no modifier is specified, then by default, a method is accessible only within its defining package
For example, programmers can choose to implement sensitive functions as private methods. The compiler and the runtime checks ensure that no objects outside the class can invoke the private methods.
Topics related articles:
[link widoczny dla zalogowanych]
[link widoczny dla zalogowanych]
[link widoczny dla zalogowanych]
Post został pochwalony 0 razy
|
|