Skip to content

Commit

Permalink
sync from alibaba:fix bug alibaba#7 alibaba#7
Browse files Browse the repository at this point in the history
  • Loading branch information
董炼师 committed Sep 17, 2015
1 parent 6654452 commit b02d043
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 42 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ bug fix process:
<dependency>
<groupId>com.alipay.euler</groupId>
<artifactId>andfix</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<type>aar</type>
</dependency>
```
or gradle dependency:

```
dependencies {
compile 'com.alipay.euler:andfix:0.3.0@aar'
compile 'com.alipay.euler:andfix:0.3.1@aar'
}
```

Expand Down Expand Up @@ -137,6 +137,11 @@ usage: apkpatch -m <apatch_path...> -k <keystore> -p <***> -a <alias> -e <***>

The libraries javadoc can be found [here](https://rawgit.com/alibaba/AndFix/master/docs/index.html)

## Security

- verify the signature of patch file
- verify the fingerprint of optimize file

## Contact

...
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ext {
siteUrl = 'https://github.com/alibaba/AndFix'
gitUrl = 'https://github.com/alibaba/AndFix.git'

libraryVersion = '0.3.0'
libraryVersion = '0.3.1'

developerId = 'supern'
developerName = 'Supern Lee'
Expand Down
59 changes: 25 additions & 34 deletions jni/art/art_5_1.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,33 @@ class Object {
};
class Class: public Object {
public:
// A magic value for reference_instance_offsets_. Ignore the bits and walk the super chain when
// this is the value.
// [This is an unlikely "natural" value, since it would be 30 non-ref instance fields followed by
// 2 ref instance fields.]
static constexpr uint32_t kClassWalkSuper = 0xC0000000;
// Interface method table size. Increasing this value reduces the chance of two interface methods
// colliding in the interface method table but increases the size of classes that implement
// (non-marker) interfaces.
static constexpr size_t kImtSize = 0; //IMT_SIZE;
// Defining class loader, or null for the "bootstrap" system loader.
static constexpr size_t kImtSize = 64; //IMT_SIZE;
// defining class loader, or NULL for the "bootstrap" system loader
void* class_loader_;
// For array classes, the component class object for instanceof/checkcast
// (for String[][][], this will be String[][]). null for non-array classes.
// (for String[][][], this will be String[][]). NULL for non-array classes.
void* component_type_;
// DexCache of resolved constant pool entries (will be null for classes generated by the
// DexCache of resolved constant pool entries (will be NULL for classes generated by the
// runtime such as arrays and primitive classes).
void* dex_cache_;
// Short cuts to dex_cache_ member for fast compiled code access.
void* dex_cache_strings_;
// static, private, and <init> methods
void* direct_methods_;
// instance fields
//
// These describe the layout of the contents of an Object.
// Note that only the fields directly declared by this class are
// listed in ifields; fields declared by a superclass are listed in
// the superclass's Class.ifields.
//
// All instance fields that refer to objects are guaranteed to be at
// the beginning of the field list. num_reference_instance_fields_
// specifies the number of reference fields.
void* ifields_;
// The interface table (iftable_) contains pairs of a interface class and an array of the
// interface methods. There is one pair per interface supported by this class. That means one
// pair for each interface we support directly, indirectly via superclass, or indirectly via a
Expand All @@ -78,7 +84,9 @@ class Class: public Object {
void* iftable_;
// Descriptor for the class such as "java.lang.Class" or "[C". Lazily initialized by ComputeName
void* name_;
// The superclass, or null if this is java.lang.Object, an interface or primitive type.
// Static fields
void* sfields_;
// The superclass, or NULL if this is java.lang.Object, an interface or primitive type.
void* super_class_;
// If class verify fails, we must return same error on subsequent tries.
void* verify_error_class_;
Expand All @@ -90,19 +98,7 @@ class Class: public Object {
// virtual_ methods_ for miranda methods.
void* vtable_;
// Access flags; low 16 bits are defined by VM spec.
// Note: Shuffled back.
uint32_t access_flags_;
// instance fields
//
// These describe the layout of the contents of an Object.
// Note that only the fields directly declared by this class are
// listed in ifields; fields declared by a superclass are listed in
// the superclass's Class.ifields.
//
// ArtField arrays are allocated as an array of fields, and not an array of fields pointers.
uint64_t ifields_;
// Static fields
uint64_t sfields_;
// Total size of the Class instance; used when allocating storage on gc heap.
// See also object_size_.
uint32_t class_size_;
Expand All @@ -114,23 +110,20 @@ class Class: public Object {
// Type index in dex file.
// TODO: really 16bits
int32_t dex_type_idx_;
// Number of static fields.
uint32_t num_instance_fields_;
// Number of instance fields that are object refs.
uint32_t num_reference_instance_fields_;
// Number of static fields that are object refs,
uint32_t num_reference_static_fields_;
// Number of static fields.
uint32_t num_static_fields_;
// Total object size; used when allocating storage on gc heap.
// (For interfaces and abstract classes this will be zero.)
// See also class_size_.
uint32_t object_size_;
// The lower 16 bits contains a Primitive::Type value. The upper 16
// bits contains the size shift of the primitive type.
uint32_t primitive_type_;
// Primitive type value, or Primitive::kPrimNot (0); set for generated primitive classes.
void* primitive_type_;
// Bitmap of offsets of ifields.
uint32_t reference_instance_offsets_;
// Bitmap of offsets of sfields.
uint32_t reference_static_offsets_;
// State of class initialization.
void* status_;
// TODO: ?
Expand All @@ -149,17 +142,16 @@ class Class: public Object {
static void* java_lang_Class_;
};

class ArtField{
class ArtField : public Object{
public:
void* declaring_class_;
Class* declaring_class_;
int32_t access_flags_;
int32_t field_dex_idx_;
int32_t offset_;
};

class ArtMethod: public Object {
public:

// Field order required by test "ValidateFieldOrderOfJavaCppUnionClasses".
// The class we are a part of.
Class* declaring_class_;
Expand Down Expand Up @@ -188,11 +180,10 @@ class ArtMethod: public Object {
// Pointer to JNI function registered to this method, or a function to resolve the JNI function.
void* entry_point_from_jni_;
// Method dispatch from quick compiled code invokes this pointer which may cause bridging into
// the interpreter.
// portable compiled code or the interpreter.
void* entry_point_from_quick_compiled_code_;
} ptr_sized_fields_;
static void* java_lang_reflect_ArtMethod_;

};

}
Expand Down
2 changes: 1 addition & 1 deletion jni/art/art_method_replace_5_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void replace_5_0(JNIEnv* env, jobject src, jobject dest) {
smeth->declaring_class_->class_loader_; //for plugin classloader
dmeth->declaring_class_->clinit_thread_id_ =
smeth->declaring_class_->clinit_thread_id_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_-1;

smeth->declaring_class_ = dmeth->declaring_class_;
smeth->access_flags_ = dmeth->access_flags_;
Expand Down
6 changes: 3 additions & 3 deletions jni/art/art_method_replace_5_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void replace_5_1(JNIEnv* env, jobject src, jobject dest) {
smeth->declaring_class_->class_loader_; //for plugin classloader
dmeth->declaring_class_->clinit_thread_id_ =
smeth->declaring_class_->clinit_thread_id_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_-1;

smeth->declaring_class_ = dmeth->declaring_class_;
smeth->dex_cache_resolved_types_ = dmeth->dex_cache_resolved_types_;
Expand All @@ -72,7 +72,7 @@ void replace_5_1(JNIEnv* env, jobject src, jobject dest) {
smeth->ptr_sized_fields_.entry_point_from_quick_compiled_code_ =
dmeth->ptr_sized_fields_.entry_point_from_quick_compiled_code_;

LOGD("replace_m: %d , %d",
LOGD("replace_5_1: %d , %d",
smeth->ptr_sized_fields_.entry_point_from_quick_compiled_code_,
dmeth->ptr_sized_fields_.entry_point_from_quick_compiled_code_);

Expand All @@ -82,5 +82,5 @@ void setFieldFlag_5_1(JNIEnv* env, jobject field) {
art::mirror::ArtField* artField =
(art::mirror::ArtField*) env->FromReflectedField(field);
artField->access_flags_ = artField->access_flags_ & (~0x0002) | 0x0001;
LOGD("setFieldFlag_m: %d ", artField->access_flags_);
LOGD("setFieldFlag_5_1: %d ", artField->access_flags_);
}
2 changes: 1 addition & 1 deletion jni/art/art_method_replace_6_0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void replace_6_0(JNIEnv* env, jobject src, jobject dest) {
smeth->declaring_class_->class_loader_; //for plugin classloader
dmeth->declaring_class_->clinit_thread_id_ =
smeth->declaring_class_->clinit_thread_id_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_;
dmeth->declaring_class_->status_ = smeth->declaring_class_->status_-1;

smeth->declaring_class_ = dmeth->declaring_class_;
smeth->dex_cache_resolved_types_ = dmeth->dex_cache_resolved_types_;
Expand Down
Binary file modified libs/armeabi/libandfix.so
Binary file not shown.
Binary file modified libs/x86/libandfix.so
Binary file not shown.

0 comments on commit b02d043

Please sign in to comment.