Skip to content

Commit

Permalink
Merge pull request #16 from win32kbase/master
Browse files Browse the repository at this point in the history
Create a base dynamic class and make constant pool dynamic entries extend it
  • Loading branch information
Col-E authored Mar 11, 2022
2 parents 5539adb + ee68c03 commit 5be01f3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 75 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>me.coley</groupId>
<artifactId>cafedude</artifactId>
<url>https://github.com/Col-E/CAFED00D/</url>
<version>1.9.5</version>
<version>1.9.6</version>
<name>CAFED00D</name>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package me.coley.cafedude.classfile.constant;

/**
* Base dynamic value pool entry. Points to a {@link CpNameType NameType} constant
* and a bootstrap method index in the class's bootstrap-methods attribute.
*
* @author Matt Coley
* @author Wolfie / win32kbase
*/
public abstract class ConstDynamic extends ConstPoolEntry {
private int bsmIndex;
private int nameTypeIndex;

/**
* @param type
* Dynamic pool entry type.
* @param bsmIndex
* Index in the class's bootstrap method attribute-table.
* @param nameTypeIndex
* Index of {@link CpNameType} in pool.
*/
public ConstDynamic(int type, int bsmIndex, int nameTypeIndex) {
super(type);
this.bsmIndex = bsmIndex;
this.nameTypeIndex = nameTypeIndex;
}

/**
* @return Index in the class's bootstrap method attribute-table.
*/
public int getBsmIndex() {
return bsmIndex;
}

/**
* @param bsmIndex
* New index in the class's bootstrap method attribute-table.
*/
public void setBsmIndex(int bsmIndex) {
this.bsmIndex = bsmIndex;
}

/**
* @return Index of {@link CpNameType} in pool.
*/
public int getNameTypeIndex() {
return nameTypeIndex;
}

/**
* @param nameTypeIndex
* New index of {@link CpNameType} in pool.
*/
public void setNameTypeIndex(int nameTypeIndex) {
this.nameTypeIndex = nameTypeIndex;
}
}
40 changes: 3 additions & 37 deletions src/main/java/me/coley/cafedude/classfile/constant/CpDynamic.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,16 @@
* and a bootstrap method index in the class's bootstrap-methods attribute.
*
* @author Matt Coley
* @author Wolfie / win32kbase
*/
public class CpDynamic extends ConstPoolEntry {
private int bsmIndex;
private int nameTypeIndex;

public class CpDynamic extends ConstDynamic {
/**
* @param bsmIndex
* Index in the class's bootstrap method attribute-table.
* @param nameTypeIndex
* Index of {@link CpNameType} in pool.
*/
public CpDynamic(int bsmIndex, int nameTypeIndex) {
super(DYNAMIC);
this.bsmIndex = bsmIndex;
this.nameTypeIndex = nameTypeIndex;
}

/**
* @return Index in the class's bootstrap method attribute-table.
*/
public int getBsmIndex() {
return bsmIndex;
}

/**
* @param bsmIndex
* New index in the class's bootstrap method attribute-table.
*/
public void setBsmIndex(int bsmIndex) {
this.bsmIndex = bsmIndex;
}

/**
* @return Index of {@link CpNameType} in pool.
*/
public int getNameTypeIndex() {
return nameTypeIndex;
}

/**
* @param nameTypeIndex
* New index of {@link CpNameType} in pool.
*/
public void setNameTypeIndex(int nameTypeIndex) {
this.nameTypeIndex = nameTypeIndex;
super(DYNAMIC, bsmIndex, nameTypeIndex);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,16 @@
* and a bootstrap method index in the class's bootstrap-methods attribute.
*
* @author Matt Coley
* @author Wolfie / win32kbase
*/
public class CpInvokeDynamic extends ConstPoolEntry {
private int bsmIndex;
private int nameTypeIndex;

public class CpInvokeDynamic extends ConstDynamic {
/**
* @param bsmIndex
* Index in the class's bootstrap method attribute-table.
* @param nameTypeIndex
* Index of {@link CpNameType} in pool.
*/
public CpInvokeDynamic(int bsmIndex, int nameTypeIndex) {
super(INVOKE_DYNAMIC);
this.bsmIndex = bsmIndex;
this.nameTypeIndex = nameTypeIndex;
}

/**
* @return Index in the class's bootstrap method attribute-table.
*/
public int getBsmIndex() {
return bsmIndex;
}

/**
* @param bsmIndex
* New index in the class's bootstrap method attribute-table.
*/
public void setBsmIndex(int bsmIndex) {
this.bsmIndex = bsmIndex;
}

/**
* @return Index of {@link CpNameType} in pool.
*/
public int getNameTypeIndex() {
return nameTypeIndex;
}

/**
* @param nameTypeIndex
* New index of {@link CpNameType} in pool.
*/
public void setNameTypeIndex(int nameTypeIndex) {
this.nameTypeIndex = nameTypeIndex;
super(INVOKE_DYNAMIC, bsmIndex, nameTypeIndex);
}
}

0 comments on commit 5be01f3

Please sign in to comment.