Skip to content

[TG-1058] Fixes parsing errors relating inner classes on generic classes #1512

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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