Skip to content

Commit

Permalink
JACOBIN-575 Added logic in instantiate.go to put entries for all of a…
Browse files Browse the repository at this point in the history
… class's methods into the GMT and into the class's MethodList
  • Loading branch information
platypusguy committed Jan 16, 2025
1 parent 0c8a871 commit 3b62d18
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/classloader/classes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type ClData struct {
Pkg string // package name, if any. (so named, b/c 'package' is a golang keyword)
Interfaces []uint16 // indices into UTF8Refs
Fields []Field
MethodList []string // sorted list of method names including superclass methods. Is the key to GMT
MethodList []string // sorted list of method names including superclass methods. Is key to GMT
MethodTable map[string]*Method // the methods defined in this class
Attributes []Attr
SourceFile string
Expand Down
2 changes: 1 addition & 1 deletion src/config/buildno.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

package config

var BuildNo = 3420
var BuildNo = 3421
26 changes: 25 additions & 1 deletion src/jvm/instantiate.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func InstantiateClass(classname string, frameStack *list.List) (any, error) {
// and work our way down to the present class, adding fields to FieldTable.
// so we add the present class into position[0] and then loop through
// the slice of class names
superclasses = append([]string{classname}, superclasses...) // CURR: JACOBIN-575 we need to add methods to GMT
superclasses = append([]string{classname}, superclasses...)
for j := len(superclasses) - 1; j >= 0; j-- {
superclassName := superclasses[j]
c := classloader.MethAreaFetch(superclassName)
Expand All @@ -170,6 +170,30 @@ func InstantiateClass(classname string, frameStack *list.List) (any, error) {
} // end of handling fields for one class or superclass
} // end of handling fields for classes with superclasses other than Object

// set up the methods in the MethodList and the GMT
for _, meth := range k.Data.MethodTable {
methName := k.Data.CP.Utf8Refs[meth.Name]
methType := k.Data.CP.Utf8Refs[meth.Desc]
FQN := classname + "." + methName + methType
k.Data.MethodList = append(k.Data.MethodList, FQN)
classloader.GmtAddEntry(FQN, classloader.GmtEntry{MethData: &meth, MType: 'J'})
}
// go through the superclasses and add their methods to the class's MethodList
for _, superclassName := range superclasses {
superclass := classloader.MethAreaFetch(superclassName)
if superclass == nil {
errMsg := fmt.Sprintf("InstantiateClass: MethAreaFetch(superclass: %s) failed", superclassName)
trace.Error(errMsg)
}

// for _, m := range superclass.Data.MethodTable { // CURR JACOBIN-575
// _, ok := k.Data.MethodTable[m.Name]
// if !ok {
// k.Data.MethodTable[m.Name] = m
// }
// }
}

runInitializer:
// check the code for validity before running initialization blocks
if !k.CodeChecked && !util.IsFilePartOfJDK(&classname) { // we don't code check JDK classes
Expand Down

0 comments on commit 3b62d18

Please sign in to comment.