Skip to content

Commit

Permalink
Merge pull request #1512 from thk123/bugfix/TG-1058/crash-inner-class…
Browse files Browse the repository at this point in the history
…-generic-class

[TG-1058] Fixes parsing errors relating inner classes on generic classes
  • Loading branch information
Thomas Kiley authored Oct 26, 2017
2 parents bd2e9c2 + f892f4a commit f9af374
Show file tree
Hide file tree
Showing 11 changed files with 1,697 additions and 148 deletions.
399 changes: 254 additions & 145 deletions src/java_bytecode/java_types.cpp

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ class java_generic_parametert:public reference_typet
{
public:
typedef symbol_typet type_variablet;
typedef std::vector<type_variablet> type_variablest;

java_generic_parametert(
const irep_idt &_type_var_name,
Expand All @@ -108,6 +107,8 @@ class java_generic_parametert:public reference_typet
return type_variables().front();
}

private:
typedef std::vector<type_variablet> type_variablest;
const type_variablest &type_variables() const
{
return (const type_variablest &)(find(ID_type_variables).get_sub());
Expand Down
4 changes: 2 additions & 2 deletions src/java_bytecode/java_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,9 @@ size_t find_closing_delimiter(

while(c_pos<=end_pos)
{
if(src[c_pos]=='<')
if(src[c_pos] == open_char)
depth++;
else if(src[c_pos]=='>')
else if(src[c_pos] == close_char)
{
if(depth==0)
return c_pos;
Expand Down
Binary file not shown.
Binary file not shown.
109 changes: 109 additions & 0 deletions unit/java_bytecode/java_bytecode_parse_generics/GenericClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
public class GenericClass<T>
{
class InnerClass
{
}

class GenericInnerClass<V>
{
V field;

class DoublyNestedInnerClass
{

}

class DoublyNestedInnerGenericClass<U>
{
T field;
}
}

class SameGenericParamInnerClass<T>
{
T field;
}

InnerClass field;
GenericInnerClass<Foo> field2;
GenericInnerClass<T> field3;

GenericInnerClass<Foo>.DoublyNestedInnerClass field4;
GenericInnerClass<T>.DoublyNestedInnerClass field5;

GenericInnerClass<Foo>.DoublyNestedInnerGenericClass<Foo> field6;
GenericInnerClass<T>.DoublyNestedInnerGenericClass<T> field7;

void method(InnerClass input)
{

}

void method2(InnerClass input, InnerClass input2)
{

}


void method3(GenericInnerClass<Foo> input)
{

}

void method4(GenericInnerClass<T> input)
{

}

void method5(GenericInnerClass<Foo>.DoublyNestedInnerClass input)
{

}

void method6(GenericInnerClass<T>.DoublyNestedInnerClass input)
{

}

void method7(GenericInnerClass<Foo>.DoublyNestedInnerGenericClass<Foo> input)
{

}

void method8(GenericInnerClass<T>.DoublyNestedInnerGenericClass<T> input)
{

}

InnerClass ret_method1()
{
return null;
}

GenericInnerClass<Foo> ret_method2()
{
return null;
}

GenericInnerClass<T> ret_method3()
{
return null;
}

GenericInnerClass<Foo>.DoublyNestedInnerClass ret_method4()
{
return null;
}
GenericInnerClass<T>.DoublyNestedInnerClass ret_method5()
{
return null;
}
GenericInnerClass<Foo>.DoublyNestedInnerGenericClass<Foo> ret_method6()
{
return null;
}
GenericInnerClass<T>.DoublyNestedInnerGenericClass<T> ret_method7()
{
return null;
}
}
Loading

0 comments on commit f9af374

Please sign in to comment.