Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for JEP 181: Nest-Based Access Control #3

Merged
merged 6 commits into from
Jun 11, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<groupId>com.mobidevelop.robovm</groupId>
<version>2.5.0-8-SNAPSHOT</version>
dkimitsa marked this conversation as resolved.
Show resolved Hide resolved
<version>2.5.0-8</version>
<artifactId>robovm-soot</artifactId>
<name>Soot</name>
<packaging>jar</packaging>
Expand Down
15 changes: 14 additions & 1 deletion src/soot/coffi/ClassFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,20 @@ else if (s.compareTo(attribute_info.EnclosingMethod)==0){
ea.method_index = d.readUnsignedShort();
a = (attribute_info)ea;
}
else if(s.compareTo(attribute_info.InnerClasses)==0)
else if (s.compareTo(attribute_info.NestHost)==0){
NestHost_attribute ea = new NestHost_attribute();
ea.class_index = d.readUnsignedShort();
a = (attribute_info)ea;
}
else if (s.compareTo(attribute_info.NestMembers)==0){
NestMembers_attribute ea = new NestMembers_attribute();
int number_of_classes = d.readUnsignedShort();
ea.classes = new int[number_of_classes];
for (int idx = 0; idx < number_of_classes; idx++)
ea.classes[idx] = d.readUnsignedShort();
a = (attribute_info)ea;
}
else if(s.compareTo(attribute_info.InnerClasses)==0)
{
InnerClasses_attribute ia = new InnerClasses_attribute();
ia.inner_classes_length = d.readUnsignedShort();
Expand Down
35 changes: 35 additions & 0 deletions src/soot/coffi/NestHost_attribute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Soot - a J*va Optimization Framework
* Copyright (C) 2005 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/

/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/

package soot.coffi;

/** Attribute that connects nest member with its host
* @see attribute_info
* @author Demyan Kimitsa
*/
class NestHost_attribute extends attribute_info {
public int class_index;
}

35 changes: 35 additions & 0 deletions src/soot/coffi/NestMembers_attribute.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Soot - a J*va Optimization Framework
* Copyright (C) 2005 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/

/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/

package soot.coffi;

/** Attribute that connects nest host with members
* @see attribute_info
* @author Demyan Kimitsa
*/
class NestMembers_attribute extends attribute_info {
public int[] classes;
}

12 changes: 12 additions & 0 deletions src/soot/coffi/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,18 @@ else if (coffiClass.attributes[i] instanceof EnclosingMethod_attribute){
}
bclass.addTag(new EnclosingMethodTag(class_name, method_name, method_sig));
}
else if (coffiClass.attributes[i] instanceof NestHost_attribute) {
NestHost_attribute attr = (NestHost_attribute)coffiClass.attributes[i];
String nest_host_class = ((CONSTANT_Utf8_info)coffiClass.constant_pool[((CONSTANT_Class_info)coffiClass.constant_pool[ attr.class_index]).name_index]).convert();
bclass.addTag(new NestHostTag(nest_host_class));
}
else if (coffiClass.attributes[i] instanceof NestMembers_attribute) {
NestMembers_attribute attr = (NestMembers_attribute)coffiClass.attributes[i];
String[] members = new String[attr.classes.length];
for (int idx = 0; idx < members.length; idx++)
members[idx] = ((CONSTANT_Utf8_info)coffiClass.constant_pool[((CONSTANT_Class_info)coffiClass.constant_pool[ attr.classes[idx]]).name_index]).convert();
bclass.addTag(new NestMembersTag(members));
}
else if (coffiClass.attributes[i] instanceof RuntimeVisibleAnnotations_attribute || coffiClass.attributes[i] instanceof RuntimeInvisibleAnnotations_attribute)
{
addAnnotationVisibilityAttribute(bclass, coffiClass.attributes[i], coffiClass, references);
Expand Down
12 changes: 11 additions & 1 deletion src/soot/coffi/attribute_info.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ class attribute_info {
* @see EnclosingMethod_attribute
*/
public static final String EnclosingMethod = "EnclosingMethod";


/** String by which a NestMembers attribute is recognized.
* @see NestMembers_attribute
*/
public static final String NestMembers = "NestMembers";

/** String by which a NestHost attribute is recognized.
* @see NestHost_attribute
*/
public static final String NestHost = "NestHost";

/** String by which a LocalVariableTypeTable attribute is recognized.
* @see LocalVariableTypeTable_attribute
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.Map;
import java.util.Set;

import org.omg.CORBA.UNKNOWN;

import soot.EquivalentValue;
import soot.Local;
Expand Down
58 changes: 58 additions & 0 deletions src/soot/tagkit/NestHostTag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Archie L. Cobbs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/

/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/


package soot.tagkit;

/**
* Tag keeps nest host for class (added in java 11)
*
* @author dkimitsa
*/
public class NestHostTag implements Tag {
private final String nestHostClass;

public NestHostTag(String nestHostClass) {
this.nestHostClass = nestHostClass;
}

public String getName() {
return "NestHostTag";
}

public byte[] getValue() {
return new byte[0];
}


public String getNestHostClass() {
return nestHostClass;
}

public String toString() {
return "[host=" + nestHostClass + "]";
}
}

57 changes: 57 additions & 0 deletions src/soot/tagkit/NestMembersTag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Archie L. Cobbs
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/

/*
* Modified by the Sable Research Group and others 1997-1999.
* See the 'credits' file distributed with Soot for the complete list of
* contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
*/


package soot.tagkit;

/**
* Tag keeps nest members for class (added in java 11)
*
* @author dkimitsa
*/
public class NestMembersTag implements Tag {
private final String[] nestMembers;

public NestMembersTag(String[] nestMembers) {
this.nestMembers = nestMembers;
}

public String getName() {
return "NestMembersTag";
}

public byte[] getValue() {
return new byte[0];
}

public String[] getNestMembers() {
return nestMembers;
}

public String toString() {
return "[members=" + String.join(",", nestMembers);
}
}